Stut a écrit :
On 2 Mar 2008, at 15:28, Richard wrote:
Stut a écrit :
On 2 Mar 2008, at 14:49, Richard wrote:
I would there for need to have two seperate sessions one for the
cart, and one for the members area. And sometimes I will need to
have them both open.
Is this possible ? I've searched google but not found anything
interesting, except session_name, but I still don't know how to
open two sessions or close one session but not the other, or open
a variable in a specific session ...
Just use one session. Put the data for each session into a separate
array...
$_SESSION['members'] = array('lots', 'of', 'data');
$_SESSION['cart'] = array('lots', 'of', 'money-making', 'crap');
To "disconnect" the user from one or other simply unset that
variable...
unset($_SESSION['members']);
unset($_SESSION['cart']);
KISS.
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.
-Stut
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...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php