Domain the cookie is set: http://login.localhost.org
Script used to set the cookie: Cookies.set('user', user, {expires: 365}, {domain: '.localhost.org'});
Note: User is JSON object
I then navigate to: http://test.localhost.org
Script used to produce cookie: console.log(Cookies.get());
Script produces a blank object: {}
I then navigate back to: http://login.localhost.org
Script used to echo cookie: console.log(Cookies.get());
Script produces the cookie: {user: "{"key":"value"}"}
What am I doing wrong?
It seems that the browser is failing to handle the "dot" properly. Which browser are you using?
IE11 on Windows 10.
It's no browser issue, there is a problem with the snippet you provided (I overlooked the first time):
Cookies.set('user', user, { expires: 365 }, { domain: '.localhost.org' });
As you can see above it is declaring 4 arguments, but js-cookie accepts only 3 (name, value and attributes). The domain attribute should be inside the same Object as expires:
Cookies.set('user', user, { expires: 365, domain: '.localhost.org' });
Then it is supposed to work.
Most helpful comment
It's no browser issue, there is a problem with the snippet you provided (I overlooked the first time):
As you can see above it is declaring 4 arguments, but js-cookie accepts only 3 (name, value and attributes). The
domainattribute should be inside the same Object asexpires:Then it is supposed to work.