Support » Fixing WordPress » How does WordPress handle sessions and session variables?

  • Hi All,

    Wondering if anyone can give me a clue as to how WordPress handles keeping track of user sessions?

    A simple search through the codebase for things like session_start() or $_SESSION[‘etc’] = ‘thing’ doesn’t appear to show that what I would think of as ‘normal’ session handling is taking place.

    Many thanks,

    pt

Viewing 6 replies - 1 through 6 (of 6 total)
  • WordPress does not use sessions in any way at all.

    Hi Otto42,

    Thanks for the reply. Then, do you have any idea how WordPress maintains state across pages?

    Is it essentially through cookies rather than sessions, or some other method?

    Many thanks,

    pt

    WordPress does not have any states to maintain across pages that I am aware of. It’s stateless in all cases that I can think of. The only case that’s really close is where you activate a plugin or something and a message is displayed on the next screen. This is done by redirection to a url with an extra get variable passed along.

    The cookies are basically an authentication cookie, saying who you are. They don’t contain any other information than your username and a form of proof that you knew the password at some point in time.

    Are there any guidelines concerning use of sessions, in case I require it in my plugin? I wasn’t able to find any resources. (All I found is this forum post)

    PLease use this; works fine in my plugins or other custom fucntions

    <?php
    if ( !session_id() )
    	session_start();

    Hi,

    Refer this plugin:

    http://wordpress.org/extend/plugins/session-manager/

    Thanks,

    Shane G.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How does WordPress handle sessions and session variables?’ is closed to new replies.