Re: Overriding session length in existing session?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I think that my suggestion is still a valid solution, someone correct
me if I'm wrong.  Let's say your code went like this:

session_start();

 // Check to see if the session variable has already been set, if not
if (!isset($_SESSION['var'])){

        // Check to see if it's been stored in a cookie
	if (isset($_COOKIE['var'])){
		$_SESSION['var'] = $_COOKIE['var'];
	}

        // If not, set the session variable and store it in a cookie for 7 days
	else{
		$_SESSION['var'] = "value";
		setcookie ("var", $_SESSION['var'], time()+86400 * 7, "/", ".domain.com");
	}
}	
echo "Here I am using my session variable, it's value is ".$_SESSION['var'];


So if that's in the header of every page, but you want to make an
acception if the person is using a public computer, you just add
something like:

if ($_POST['public_terminal'] === TRUE){

    // "Delete" the cookie
    setcookie("var","",time() - 3600);	
}

echo "Here I am *still* using my session variable, it's value is
".$_SESSION['var']." and it will expire when the browser closes";


Marc

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux