tags:

views:

99

answers:

3

I have a problem with the session_id(). When I call the session_destroy(), by going specifically to the logout page and then I go back to my start page the session_id is still the same. What to do? But when I close the browser window the session_id is a new one, but what if a person not closes his/her browser window?

+4  A: 

session_destroy() destroys the session data on the server, not the session id in the cookie. Either use setcookie() to unset the cookie or use session_regenerate_id() to get a new ID.

johannes
session_regenerate_id() is the correct function name (http://de.php.net/manual/en/function.session-regenerate-id.php)
Thomas
A: 

The order of regeneration and destroying variables is important:

function _session_destroy() {
    session_regenerate_id();
    session_destroy();
}
cballou
A: 

use these function as in order shown below

session_start();
session_unset();
/* Kill all session variables */
   unset($_SESSION['variable1']);
   unset($_SESSION['variable2']);
   .
   .
   .
   .
   .
   unset($_SESSION['variableN']);


   $_SESSION = array(); // reset session array

/* now generate session id */ 

   session_regenerate_id();
   session_destroy();   // destroy session.
diEcho