Link to home
Start Free TrialLog in
Avatar of starfailure
starfailureFlag for United States of America

asked on

problem w/ sessions

Hi folks.
I'm kinda new at this, but I'm having trouble retrieving (or setting) Session variables.  They seem to be lost whenever the page reloads.
Aren't they supposed to remain until unset or until the browser is closed?

brief summary of what i'm doing:

at the top of the page:

if(!isset($_SESSION)) {
      session_start();
      header("Cache-control: private");
}

if ($action == "logout") {
      $_SESSION = array();
                session_unregister();
      session_unset();
}


if ($action == "login") {
                $_SESSION['login'] = 1;
}

if ($_SESSION['login'] ==1) {
                stuff;
} else { other stuff;  }


Now, I don't think I'm properly checking whether or not the session is set.  Basically, I don't want it to be destroyed until the user logs out or closes the browser window.

Am I using the Session functions incorrectly?
Is there a better way to check whether a user is logged in or out in this scenario?







ASKER CERTIFIED SOLUTION
Avatar of herkules85
herkules85

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial