0

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?

David Jarrin
  • 1,635
  • 4
  • 19
  • 40
  • Possible duplicate of [Problems deleting cookies, won't unset](http://stackoverflow.com/questions/2856366/problems-deleting-cookies-wont-unset) – Hackerman Sep 30 '16 at 15:54

2 Answers2

0

Set the time to Thu, 01-Jan-1970 00:00:01 GMT. I believe it will solve the problem

Kofi Mokome
  • 189
  • 3
  • 12
0

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

Michael
  • 1,063
  • 14
  • 32
  • Still no luck, I find it odd I can delete with js on local but not my staging server. Think there could be some weird server settings? – David Jarrin Sep 30 '16 at 16:18