7

I try to delete cookie set by http header but doesn't work. What's the different between http-set cookie and javascript-set cookie ?

HOT.CHO
  • 769
  • 2
  • 6
  • 7
  • 3
    The answer is in here: [How to Delete Session Cookie?](http://stackoverflow.com/questions/1085756/how-to-delete-session-cookie). If a cookie is set with `HttpOnly`, you cannot access it from JS. – CodeCaster Mar 14 '13 at 11:24
  • 1
    Are they HTTPOnly cookies? Can your JavaScript read them? – penguat Mar 14 '13 at 11:30

1 Answers1

11

Yes, javascript can delete a cookie set by HTTP headers unless it is specifically a HTTPOnly cookie.

The cookie must also be from the same domain as the javascript.

See also http://www.quirksmode.org/js/cookies.html and Clearing all cookies with JavaScript

Community
  • 1
  • 1
penguat
  • 1,337
  • 1
  • 13
  • 25