WordPress killing Sessions? (6 posts)

  1. Courtman
    Posted 8 years ago #

    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:

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

    Thanks for your help!

  2. mfffield
    Posted 8 years ago #

    I'm having a similar problem to this. Did you ever figure it out?

  3. thebindlestick
    Posted 8 years ago #

    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.

  4. noyz319
    Posted 7 years ago #

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

  5. RexSilex
    Posted 7 years ago #

    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.

  6. janenef
    Posted 7 years ago #

    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:

    [number_of_years] =>

    Any help would be greatly appreciated.

Topic Closed

This topic has been closed to new replies.

About this Topic