WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know that Wordpress is stateless and doesn't use any global session variables, but when a user logs in via Wordpress, it must somehow keep track of who is logged in, right? Does Wordpress keep track of that in cookies?

I'm working on a plugin that must keep track of something similar. I can easily store some data in transients, but is there a unique identifier available that can identify a user, whether he or she is logged in to Wordpress or not? I would then use that to access the transient, for example.

share|improve this question
up vote 2 down vote accepted

Yes, WordPress uses cookie to keep track of who is logged in in cookies. But you don't have to rely on it. If you want to check if user is logged in, you can just use is_user_logged_in function and you can identify a user by his/her ID which you can get by calling get_current_user_id function.

share|improve this answer
Right, but this also has to work if a user is not logged in to Wordpress. Is there a unique user identifier for just visitors that I can retrieve? – NightHawk Jun 1 '12 at 14:55
@NightHawk Use your own cookie for it. – Eugene Manuilov Jun 1 '12 at 14:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.