Giter Club home page Giter Club logo

Comments (19)

carhartl avatar carhartl commented on May 19, 2024

This is just the way how cookies work in any browser by default. I am reluctant to change that behavior.

from jquery-cookie.

carhartl avatar carhartl commented on May 19, 2024

I.e. I am reluctant to change any behavior in such fundamental way. It's too obtrusive.

from jquery-cookie.

ssoroka avatar ssoroka commented on May 19, 2024

let's at least add this to the documentation.

from jquery-cookie.

jaloplo avatar jaloplo commented on May 19, 2024

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.

betamos avatar betamos commented on May 19, 2024

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.

carhartl avatar carhartl commented on May 19, 2024

I will add that to the README. Though I am nearly convinced that path = '/' should become default.

from jquery-cookie.

betamos avatar betamos commented on May 19, 2024

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.

kaore avatar kaore commented on May 19, 2024

I just spent 2 hours on a problem linked to that default path not being '/' thing...

from jquery-cookie.

carhartl avatar carhartl commented on May 19, 2024

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.

xiatica avatar xiatica commented on May 19, 2024

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.

carhartl avatar carhartl commented on May 19, 2024

You're using it wrong, options are a single argument.

$.cookie("myCookie", "0", { expires:7, path: '/', domain: "local.mysite.test" })

from jquery-cookie.

xiatica avatar xiatica commented on May 19, 2024

So I was. Thanks for the reply carhartl.

from jquery-cookie.

Lumerc avatar Lumerc commented on May 19, 2024

'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.

carhartl avatar carhartl commented on May 19, 2024

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.

Lumerc avatar Lumerc commented on May 19, 2024

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.

brycenesbitt avatar brycenesbitt commented on May 19, 2024

I'm here because I too was caught unaware by this behavior.

from jquery-cookie.

FagnerMartinsBrack avatar FagnerMartinsBrack commented on May 19, 2024

@brycenesbitt but now this is properly documented at https://github.com/carhartl/jquery-cookie#path

from jquery-cookie.

thujone avatar thujone commented on May 19, 2024

weird default path messed me up

from jquery-cookie.

brycenesbitt avatar brycenesbitt commented on May 19, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.