Skip to content Skip to sidebar Skip to footer

JavaScript Cookie Absolutely Refuses To Be Deleted

This is related to my other question, i'm asking a new question as i've narrowed down the problem and the original question was getting rather convoluted. In a nutshell, i have a c

Solution 1:

This was solved by removing the domain altogether!

document.cookie = 'session=xyz; path=/; domain=;";

Hope this helps someone else, as this has been an absolute bitch to diagnose

EDIT

So in a cruel twist of fate, this does indeed fix the issue for chrome and firefox, but you guessed it - IE/Edge is now throwing the toys out of the pram!

I give up


Solution 2:

I know you don't want to use dependencies unless necessary, but JS-Cookie is an extremely lightweight, extensively tested library that is cross compatible; it shouldn't affect performance and could be exactly what you're looking for

Here's a link to the GitHub repo.

Cheers!


Solution 3:

Use jQuery cookie library instead of accessing document.cookie directly https://plugins.jquery.com/cookie/

Then just use it like jQuery.cookie('session','xyz',{ path: '/' });


Post a Comment for "JavaScript Cookie Absolutely Refuses To Be Deleted"