javascript - Cookie not being deleted after session closed -


i'm using cookies should deleted after user closes page, they're not. how set cookies js

document.cookie="status=false"; 

i can see cookie in console , after close browser , open again , go webpage there's still cookie status=false idea why?

document.cookie = ... sets individual cookie values, not set "the entire cookie" string passed, setting "status=false" binds or updates "status" value, irrespective of whatever else in cookie:

document.cookie = "cow=bell"; document.cookie = "cat=lol"; // cookie "cow=bell&cat=lol", not "cat=lol" 

if want delete entire cookie, set expiration time "in past" , browser cleanup you.

(as pointed out in comment, if never set expiration timestamp cookie, it'l expire when page session ends, e.g. close tab/browser)


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -