I'm using js-cookie:
It's easy to set a cookie, but I'm unclear how to output specific values and test against them. This works fine:
Cookies.set('newsletter', 'show', { expires: 30, path: '/' });
var myCookie = Cookies.get('newsletter');
But this does not:
if(myCookie){
var p = Cookies.get(['expires']);
document.write(p);
}
How do I access the expires
property?
According to this issue it is not possible
It‘s not possible.
Also in the FAQ it states the same thing:
It's not possible. Once the cookie has been written, its attributes can‘t be read out. The underlying API we‘re constraint to use doesn‘t support this: https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie