Support » Fixing WordPress » Custom Session Variables Unset immediately?

  • 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?

Viewing 5 replies - 1 through 5 (of 5 total)
  • I was wondering about the same thing

    I have exactely the same problem 🙁

    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…

    lourencobasso
    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.

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

    session_start();

    This enabled sessions.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom Session Variables Unset immediately?’ is closed to new replies.