Reputation: 65
I'm trying to destroy visitors cookie
and session
at same time when he/she logs out. Like this:
setcookie($id, '', time()-13600, "/");
unset($_SESSION[$id]);
Although cookie
destroys but user is still logged in because session
not destroying.
Note: I can't use
session_unset()
because it will destroy all the sessions.
PS: I solved my problem just by not setting session but only cookie, still i can't solve problem i asked above.
Upvotes: 0
Views: 107
Reputation: 833
well you could use session_destroy() in order to unset the session for current user. the rest of sessions will stay unchanged. this is how you do it
<?php
session_destroy();
Upvotes: 1
Reputation: 4103
for destroy all sessions use this code
<?php
session_destroy();
for unset any session you can do it by session : key
<?php
unset($_SESSION['key_name']);
Upvotes: 0