Comments (19)
This is just the way how cookies work in any browser by default. I am reluctant to change that behavior.
from jquery-cookie.
I.e. I am reluctant to change any behavior in such fundamental way. It's too obtrusive.
from jquery-cookie.
let's at least add this to the documentation.
from jquery-cookie.
I'm totally agree with ssoroka. I was facing the same problem til I read these comments. Add this to the documentation, please.
from jquery-cookie.
I was also completely fooled by this. Hours of debugging. To help others out, maybe you could add some text to your README or make it more clear in the documentation.
If you don't know how (stupid) cookies actually works, it's really hard to know what's wrong.
Cheers.
from jquery-cookie.
I will add that to the README. Though I am nearly convinced that path = '/' should become default.
from jquery-cookie.
So you changed opinion on that? I think it's a great idea. Think about the updaters, though. They may need some info on that, since it's an "API change".
from jquery-cookie.
I just spent 2 hours on a problem linked to that default path not being '/' thing...
from jquery-cookie.
The issue I still have with having a default path is that when one wants the behavior as is, you would have to pass null, which to me at least feels not intuitive at all:
$.cookie('foo', 'bar', { path: null }); // null denotes current path?
That said, I am planning to document that behavior prominently and provide a way to define defaults, so that a developer can easily turn on '/' as the default path with a single line of code. That way it'll also not break existing code.
// bulk
$.cookie.defaults = { path: '/', expires: 365 };
// single
$.cookie.defaults.path = '/';
from jquery-cookie.
I'm encountering the path issue as well. Although I am setting it so that it should only be /, but it's still saving a subdirectory if changed at that location. How can it be forced to only use tld?
I'm using the version you've got hosted here, with FF3.6.13 JQ1.4.4 and the line of code is
$.cookie("myCookie", "0", { expires:7 }, { path: '/', domain: "local.mysite.test" });
if saved at local.mysite.test/somepath it's saving the cookie path as 'local.mysite.test/somepath' instead of the tld.
from jquery-cookie.
You're using it wrong, options are a single argument.
$.cookie("myCookie", "0", { expires:7, path: '/', domain: "local.mysite.test" })
from jquery-cookie.
So I was. Thanks for the reply carhartl.
from jquery-cookie.
'global' path cookie again.
I set cookies path to '/'
but I had a problem to get this global values
if I get values from standart options: $.cookie('variable') i will get values from this page (NOT path: '/').
but logging $.cookie() object show me the really {path : '/'} values and this show me how get cookie values with my params (such a {path : '/'})
$.cookie().variable
if($.cookie().variable == 1)
{
console.debug('yes, you do this!');
}
Of course I was talking about the pages with the root directory other than '/'
browser chrome
from jquery-cookie.
I believe in your case a cookie with a path for a particular page (in case of an omitted path, the "current" page) may shadow a cookie with the same name "higher up" in the path hierarchy.
What happens if you start with a blank page, e.g. clean all cookies?
from jquery-cookie.
yes, indeed.
Thanks for the explanation. I thought that I had them cleaned.
sorry for inconvenience caused.
And thank you for this plugin!
from jquery-cookie.
I'm here because I too was caught unaware by this behavior.
from jquery-cookie.
@brycenesbitt but now this is properly documented at https://github.com/carhartl/jquery-cookie#path
from jquery-cookie.
weird default path messed me up
from jquery-cookie.
@FagnerMartinsBrack thanks much better. Having it in the example as 'Create expiring cookie, valid across entire site:' is particularly nice, since that's where the lazy will look.
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.