Hey, I am having major trouble with my sessions and I was hoping you guys could help me... I am at my wit's end here.

Basically, I am doing a simple login function with session ids, and want to store two session variables once somebody logs in - username and whether or not they are an admin.

So I have them log in and compare their username and password to my mysql database and if there is a match they get logged in, and so I set:

$_SESSION["username"] = $username

and

$_SESSION["admin"] = 0; // by default

Then I provide them with a link to go back to the main page. But as soon as they do, they change session id's and with it they lose their logged in status!

I am already storing the sessions in an explicit folder that I made with read/write/execute capabilities (chmod 777), and I have verified that the sessions are being created - they're just changing every time the page reloads!

Any idea what could be causing this to happen?

Thanks, Stephen

    I don't know if this helps anybody help me, but cookies are also doing the same thing!!! Please help...

      I have no idea... How would I go about finding that out?

        Well i assume its off,

        do you mind if you post your code?

          Sure... the following isn't the actual code but a test page I've created in the meanwhile that has the same problem:

          first page: index2.php
          <?
          session_start();

          $HTTP_SESSION_VARS["loggedIn"] = "yes";
          $_COOKIE["isLoggedIn"] = "yes";

          print "<a href='test2.php' target='_self'>click here</a>";

          phpinfo();

          ?>

          second page: test2.php

          <?
          session_start();

          $loggedIn = $HTTP_SESSION_VARS["loggedIn"];
          $isLoggedIn = $_COOKIE["isLoggedIn"];

          print $loggedIn . "<br>";
          print $isLoggedIn;

          ?>

          The output for the second page is totally blank.

            PS: The same thing happens when I replace $HTTP_SESSION_VARS with $_SESSION

              Check out the order of your variable registration. Look inside your php.ini for something like this:

              ; This directive describes the order in which PHP registers GET, POST, Cookie,
              ; Environment and Built-in variables (G, P, C, E & S respectively, often
              ; referred to as EGPCS or GPC). Registration is done from left to right, newer
              ; values override older values.
              variables_order = "EGPCS"

                Write a Reply...