phat_hip_prog Posted October 25, 2013 Share Posted October 25, 2013 this works but the session id satys after reopening browser <?php error_reporting(E_ALL); ini_set('display_errors',E_ALL); ini_set('session.use_only_cookies', 1); $cookieParams = session_get_cookie_params(); $loggedin=true; if(isset($_GET['logout'])){ session_set_cookie_params(-31536000, $cookieParams["path"], $cookieParams["domain"], false, true); //session_set_cookie_params(0, $cookieParams["path"], $cookieParams["domain"], false, true); session_start(); //session_destroy(); $loggedin=false; session_unset(); //unset($_SESSION['myvar']); session_destroy(); header("Location: http://". $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']); }elseif(isset($_GET['login'])){ session_set_cookie_params(time()+31536000, $cookieParams["path"], $cookieParams["domain"], false, true); session_start(); $_SESSION['myvar']="Logged in"; header("Location: http://". $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']); }else{ echo "lifetime: ".$cookieParams["lifetime"]."<br />"; /* if($cookieParams["lifetime"]>0){ echo "lifetime: here<br />"; session_set_cookie_params(time()+31536000, $cookieParams["path"], $cookieParams["domain"], false, true); //if($cookieParams["lifetime"]<=0){ }else{ echo "lifetime: There<br />"; session_set_cookie_params(0, $cookieParams["path"], $cookieParams["domain"], false, true); } */ //session_set_cookie_params($cookieParams["lifetime"], $cookieParams["path"], $cookieParams["domain"], false, true); session_set_cookie_params(time()+31536000, $cookieParams["path"], $cookieParams["domain"], false, true); session_start(); } //session_regenerate_id(); echo session_id()."<br />"; if(isset($_SESSION['myvar'])){ echo "myvar: ".$_SESSION['myvar']."<br />"; echo "<a href='?logout=true'>logout</a><br />"; }else{ echo "<a href='?login=true'>login</a><br />"; } ?> <br /> ... when i echo lifetime it always 0, why Link to comment https://forums.phpfreaks.com/topic/283275-sessions/ Share on other sites More sharing options...
phat_hip_prog Posted October 27, 2013 Author Share Posted October 27, 2013 bump Link to comment https://forums.phpfreaks.com/topic/283275-sessions/#findComment-1455696 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.