WordPress.org

Support

Support » How-To and Troubleshooting » WordPress killing Sessions?

WordPress killing Sessions?

  • I’ve set up my WordPress to look like the rest of my site now and its working very well. I have a small script which users log in with – either saving a cookie or a session to the computer (if they don’t tick “Remember Me”.)

    This works fine on all my other pages, basically at the top of the page it looks to see if the user has a session or cookie – if not it dumps them back to the homepage.

    I’ve put the same script at the top of the main index.php in WordPress. It works great if its a cookie, but for some reason if a session is set it determines correctly that a session is set but then closes the session after taking the user to the main weblog. Is there anywhere in the WordPress code that closes all active sessions – I can’t seem to find it?

    The script I use is this:

    session_start();
    if ( !isset($_COOKIE['peanutcookie']) AND !isset($_SESSION['peanutsession']) )
    {
    $errmsg = 1;
    header('Location: \errorbox.php?errcode='.$errmsg);
    exit;
    } else {
    /* Short and sweet */
    define('WP_USE_THEMES', true);
    require('./wp-blog-header.php');
    }

    Thanks for your help!

Viewing 5 replies - 1 through 5 (of 5 total)
  • I’m having a similar problem to this. Did you ever figure it out?

    Same here. My site goes from the WordPress index to a custom shopping cart, and the session ID is started on the first page of cart, but for some reason it isn’t working. It kicks me back to the index when the if statement in the session check fails.

    have any of you guys found a solution to this? I am having a similar problem.

    I found a workaround.
    Make sessions autostart in your php ini file. This fixed my wordpress session woes but…

    Note: This will prevent you from putting objects into session vars because the sessions will be loaded before the object definitions.

    I tried this. Now my session variable exists but it’s empty. The variable is loaded in a php script and the print_r of $_session on a WordPress page shows this:

    Array
    (
    [number_of_years] =>
    )

    Any help would be greatly appreciated.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘WordPress killing Sessions?’ is closed to new replies.
Skip to toolbar