WordPress.org

Ready to get started?Download WordPress

Forums

How does WordPress handle sessions and session variables? (7 posts)

  1. planetthoughtful
    Member
    Posted 5 years ago #

    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

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    WordPress does not use sessions in any way at all.

  3. planetthoughtful
    Member
    Posted 5 years ago #

    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

  4. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    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.

  5. shmichael
    Member
    Posted 4 years ago #

    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)

  6. Frank
    Member
    Posted 4 years ago #

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

    <?php
    if ( !session_id() )
    	session_start();
  7. Shane G.
    Member
    Posted 4 years ago #

    Hi,

    Refer this plugin:

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

    Thanks,

    Shane G.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags