• Boy I am really confused now.

    I put in a simple counter
    and it is clear that the session information is unstable.
    I am lost as to why this is please help.
    Here is the simple counter I used to test:

    <?php</p>
    <p>session_start();</p>
    <p>if (empty($_SESSION[‘count’])) {
    $_SESSION[‘count’] = 1;
    } else {
    $_SESSION[‘count’]++;
    }
    ?></p>
    <p><p>
    Hello visitor, you have seen this page <?php echo $_SESSION[‘count’]; ?> times.
    </p>

    The number changes all around and then seems to start all over. Try it yourself:

    https://www.baguachuan/blog

    Refresh the page several times and see what it does in the left sidebar.

    Please Help I am lost.

    Alfred

Viewing 5 replies - 1 through 5 (of 5 total)
  • I am no expert, but here are a couple of possibilities:

    • session_start() needs to be called before any output to the browser. Put the call before get_header() in your template.
    • Some themes and plugins use sessions to track other things, such as an order tracking system.

    If it isn’t one of those, then I am out of ideas.

    Thread Starter alfredwestlake

    (@alfredwestlake)

    Thanks vtxyzzy,
    Yea I have tried putting the session_start() in at various places. Doesnt seem to change the result.
    Thanks again for the input,
    Alfred

    Thread Starter alfredwestlake

    (@alfredwestlake)

    I have been searching around and apparently there is a problem using sessions with word press. Not sure why they are ‘disabled’. Any ideas on how to get them working would be appreciated.

    Thanks,
    Alfred

    Try going to wp-settings.php and on line 36:

    $noUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix');

    Change this to

    $noUnset = array('_SESSION', 'GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix');

    Which should never unset/disable sessions.

    arpitap

    (@arpitap)

    Hi fOObar,

    I tried this but it is still not working for me.
    Can you tell me what I could be doing wrong?

    Thanks,
    Arpita

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Hopelessly Lost Please help!! – $_SESSION’ is closed to new replies.