js-cookie value is undefined

3.4k Views Asked by At

I am trying to get the string "value" from the cookie "name" however, 'undefined' is always printing out. I am using chrome and any help would be appreciated

Here is my code:

Cookies.set('name', 'value');
var plswork = Cookies.get('name');
document.write(plswork);
1

There are 1 best solutions below

0
On

Cookies are stored in the "document.cookie" JavaScript object

var a = document.cookie; 
document.write();