note 5210 deleted from session_destroy by ronabop

From: Date: Fri, 18 Aug 2000 03:32:28 +0000
Subject: note 5210 deleted from session_destroy by ronabop
Groups: php.notes 
Request: Send a blank email to php-notes+get-2275@lists.php.net to get a copy of this message
Two problems appears with session management: 1. I first open the session with session_start(), check if the session is okay ($myobject class), and if not I do: session_destroy(); session_id(somerandomID); session_start(); $myobject=new MyObject(); PROBLEM: The first time a client loggs in, no cookie is being sent. The session is a default session with a default ID - so the ID is changed, and session reopened. BUT The "Set-Cookie:" gives two cookies with same name (WID=<first default cookie>,WID=<the new one>) and of course the browser has some problems handling two cookies wih same name! 2. there is no "lifetime" variable that can be used. so I use a class, and in the constructor I just add: $this->time=time(); /* time on current date */ $this->lifetime=30; /* max time */ And in the begining of the script: if ($session->lifetime > 0) { if ( (time() - $session->time) > $session->lifetime) { /* cookie expired */ session_destroy(); } } It's working fine - but is there a simpler way?

« previous php.notes (#2275) next »