Comments (8)
I can confirm a variation on this bug.
If I create a cookie with the following options:
$.cookie('cookie_name','cookie_val',{expires:365,path:'/'});
I can delete the cookie with:
$.cookie('cookie_name',null)
if the page is at the root level of the site.
If the page is in a sub folder, the cookie is not deleted with the above code, but will delete if I add the {expires:365,path:'/'} option.
from jquery-cookie.
I am having the same issue as Bruzie.
$.cookie( 'cookie_name', null , { expire: 7, path:'/'} );
using the following seems to work no matter what the path. This isn't reflected in the documentation.
$.cookie( 'cookie_name', null , {path:'/'} );
from jquery-cookie.
I think I'm having a related issue:
I need to delete a cookie that's set by the server, and the domain name is variable depending on the installation. I can't seem to delete the cookie unless I define the domain, so we've had to hard code it for every installation.
I'd like to be able to do this:
$.cookie( 'cookie_name', null );
or even this:
$.cookie( 'cookie_name', null, {path:'/'} );
but only this works:
$.cookie("ESID", null, { path: '/', domain: 'ourcompany.com' });
note: HttpOnly is not set on the cookie, so that's not the issue. :)
thanks!
from jquery-cookie.
@scowles4 instead of hard coding the url you could get it dynamically.
http://stackoverflow.com/questions/406192/how-to-get-the-current-url-in-jquery
Hope this helps.
from jquery-cookie.
@night815 Thank you for the suggestion.
I did play around with window.location.hostname to retrieve the domain but it picks up the subdomain as well (it returns dev.ourcompany.com when the cookie is set to ourcompany.com). The regex solution for this would trip on a cookie set to ourcompany.com.uk, for example. So it's safer to hard code the value and that's ok for the short term.
I'm editing my comment to say I'm going to work on syncing up with our own server-side logic to make sure the domain matches, that's more appropriate for my situation. :)
Thanks again - appreciate the help!
from jquery-cookie.
I think the problem is you have to know the exact path when deleting a cookie. I've had this issue with PHP many times.
I will have to test this when I get some time. If i figure out a way to do it i will submit the code to this project.
from jquery-cookie.
@kirkhelek
"so, if i want to delete a cookie using your plugin I need to put the same options that I used for its creation, really?"
Yes, when deleting a cookie, you must pass the exact same path, domain and secure options that were used to set the cookie (but not expires). That's how it works in a browser. I've updated the documentation to be more clear on this.
This will become a bit more straight forward with default options.
from jquery-cookie.
@bruzie In your case you can delete the cookie set with path: '/' at the root level that way because root is '/'.
from jquery-cookie.
Related Issues (20)
- If the cookie time is up, then the cookie value is what? undefind or null? HOT 1
- Line Break HOT 1
- Line Break HOT 9
- Request - version bump on js files or revert master HOT 12
- [NuGet] Align naming convention between minified and base .js files in package HOT 2
- $.removeCookie is not deleting cookie in Chrome HOT 13
- A Session Cookie not working HOT 8
- Cookies deleted when page open without query parameters HOT 2
- $.removeCookie is not a recognized on Chrome HOT 7
- Cookie gets restored magically after some time HOT 7
- Disable issues? HOT 2
- Escape # char
- Cookie not set in IE10 HOT 1
- Do not create an issue here! HOT 3
- Bower crashing if using jquery-cookie 1.4.1 HOT 2
- Unable to install using Bower HOT 6
- Fail update cookie? HOT 2
- jquery cookie support for http flag true HOT 2
- Cookie Https HOT 2
- suggestion: add function for parse signedcookies in next rev HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-cookie.