Reputation: 12262
I am trying to implement simple login and logout mechanism. When the user logs in I am creating the session by using session_start()
. and upon the user logging out I am calling
session_unset();
session_destroy();
but the problem is that after logging out next time if again login. the session_id()
is same as previous. No matter how much I do the session_destroy()
, the session_id()
is always the same. Does it mean session_destroy()
is not working? Or there is some other reason?
Upvotes: 2
Views: 906
Reputation: 360662
http://php.net/session_destroy
session_destroy() basically does
$_SESSION = array();
but leaves the session cookie, and the session ID stored in it, intact. You have to manually unset the cookie with a setcookie()
call, or use session_regenerate_id()
to force a new ID to be created.
Upvotes: 3
Reputation: 25745
Change
session_unset();
session_destroy();
To
session_start();
session_destroy();
As with your code session is not really being destroyed.
Upvotes: 5