Custom Session Variables Unset immediately? (6 posts)

  1. cactusphone
    Posted 9 years ago #

    I'm trying to set a custom session variable and it seems to be unset the next time the page is generated. Is this normal in wordpress? Is there a function for creating a custom session variable?

  2. Tribulant Software
    Posted 9 years ago #

    I was wondering about the same thing

  3. Mads Phikamphon
    Posted 9 years ago #

    I have exactely the same problem :(

  4. lourencobasso
    Posted 9 years ago #

    Me too!!!
    The problem is in the function wp_unregister_GLOBALS(), located in wp-settings.php.
    This fuction unset all globals variables, including the sessions variables.
    Unfortunely the code don't explain why this kind of thing is done!!!
    I'll try to change it, avoiding to unset de $_SESSION...

  5. betatea
    Posted 9 years ago #

    Actually that function only clears the corresponding values in $GLOBALS hash and does not touch the actual value in $_SESSION hash.

    So for example you set $_SESSION['key1'] and that function unsets $GLOBALS['key1'] so that $key1 become unaccessible but this does not affect $_SESSION['key1'] and you can use it after you initialize the session with session_start() function.

  6. beetlefish
    Posted 8 years ago #

    I couldn't find session_start() in my installation of WordPress so I added it to the wp-config.php file at the top.


    This enabled sessions.

Topic Closed

This topic has been closed to new replies.

About this Topic