Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.