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?
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.
The order of regeneration and destroying variables is important:
function _session_destroy() {
session_regenerate_id();
session_destroy();
}
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.
精彩评论