How to get the nid of nodes created by user (on the event of logout)? I have a  content type 'XYZ' for which the user has created nodes. Is there any way I can use to get the node ID of all the nodes created or deleted by user at the time of logout?

I am using hook_user_logout(), but I am not able to get the node IDs for the node created by the user.
hook_user_logout() is probably called only when the user uses user/logout to log out. If users don't log out all the times after they used the site, that hook is probably not going to be invoked. (For example, I have never logged out from Drupal.org, and I log in back once my session expires for the browser I am using.)
Furthermore, once a node is deleted, there is no track of it in the database, and since hook_user_logout() is going to be eventually invoked when it is too late, it is not going to find any information about the nodes deleted by the user.

I would rather use hook_node_insert() and hook_node_delete() to collect the data that will be used from another hook. For example, the following code would work.

function mymodule_node_insert($node) {
  $_SESSION['created'][$node-&gt;nid] = TRUE;
}

function mymodule_node_delete($node) {
  $_SESSION['deleted'][$node-&gt;nid] = TRUE;
}


If that is helpful information, instead of TRUE you can use REQUEST_TIME; in that way, you would log when the user created or deleted a node.

Eventually, you can use a database table instead of a session variable, but in that case you should clean it after the user logged out, if you want to reset the information you collected once the user logs out. With the code I shown, you would lose the information when the session expires for the user, so it is probably preferable for you to store the information in the database.

The method suggested by the other users doesn't work when the user creates a node and deletes it. Counting the number of nodes associated with a user ID doesn't include the nodes that have been deleted before the user logged out. Also, since users with the permission of administering nodes can associate a node with a user different from the user who created it, counting the nodes associated with a user ID is going to give wrong information.