When I look in my chrome dev tools (Cookies section) you have 5 relevant columns: Name, Value, Domain, Path and Expires / Max-Age I have a cookie that I can't delete with and Expires / Max-Age of Session. The odd thing is that when I inspect with x-debug it doesnt show up under $_SESSION it shows up under $_COOKIE.
I first tried deleting with JS, this worked on my local environment but when I pushed it up to a staging server the cookie wasnt being deleted.
Next I tired deleting it with PHP since it is my understanding that session cookies cant be deleted with js but when trying to delete the cookie with setcookie, or something like
setcookie (session_id(), "", time() - 3600);
session_destroy();
session_write_close();
I still have no luck, any suggestions?
Set the time to Thu, 01-Jan-1970 00:00:01 GMT. I believe it will solve the problem
I think that your session_write_close()
after the session_destroy()
may be an issue. Have you try to use only session_destroy()
?
You can use unset($_COOKIE[session_name()])
; to delete the cookie of the session