Re: Multiple sessions open at same time, is it possible?

From: Date: Sun, 02 Mar 2008 16:06:09 +0000
Subject: Re: Multiple sessions open at same time, is it possible?
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-270835@lists.php.net to get a copy of this message
On 2 Mar 2008, at 15:59, Richard wrote:
Stut a écrit :
On 2 Mar 2008, at 15:28, Richard wrote:
However, is there a way to limit the session stay alive time for just one variable ? If for example, if a user has not done anything in his members area for more than 30 minutes I would like to be able to reset his password, but I do not want to reset the cart. Do I have to program this seperatly in PHP (IE set a session varibale $_SESSION['last_time'] = time(); and on each page loads : if ( time() - $_SESSION[last_time] > 1800) { $_SESSION['password'] = array();
else {    $_SESSION['last_time'] = time()
} ... Or is there a better way to do this?
There is no built-in mechanism for this so you need to implement your own as above. Personally I would store it as an expiry time rather than the current time, but whatever floats ya boat.
Sorry, I only know how to use current time, just for my personal interest, how would you use expiry time ? I've looked around a bit and can't work out how you would do this without using the current time...
It's really not rocket science... if ($_SESSION['expiry'] < time()) {
    $_SESSION['password'] = array();
} else {
    // Password expires in 30 minutes
    $_SESSION['expiry'] = time() + 1800;
} Just curious... why are you setting the password to an empty array? You'd probably be better off unset'ing it so you can use isset to check for it. -Stut -- http://stut.net/

« previous php.general (#270835) next »