I have two cookies in my JS file and I want to remove them.
I have tried the code below but it is not working
$.removeCookie('filter', { path: '/Home/' }); $.removeCookie('Pfilter', { path: '/Home/' });
I have also tried the below for null cookies, but this is also not working.
Thanks for the help
$.cookie('filter',null, { path: '/Home/' });
This can be done using the cookie() and removeCookie() methods of the jquery-cookie library.
If you created it with a path / and a domain mydomain.com, then you have to delete it with those. If you did not use path or domain when creating the cookie, you can not have the path or domain when deleting it. Trick was to delete it in the EXACT same way it was created.
It might depend on what path your cookie is using. If you goto the chrome developer tools and check the path column under Resources > Cookies > Path.
You might be using the generic /
for your path instead of /Home/
. Give the code below a try.
To delete a cookie with jQuery set the value to null:
$.removeCookie('filter', { path: '/' });
Did you try $.cookie("name", null);
$.removeCookie('filter', { path: '/' });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With