1

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);
Pogrindis
  • 7,755
  • 5
  • 31
  • 44
igetstuckalot
  • 237
  • 2
  • 8
  • 16
  • Can you tell us what `Cookies` is please – Pogrindis Feb 24 '16 at 17:58
  • http://stackoverflow.com/questions/14573223/set-cookie-and-get-cookie-with-javascript possibly duplicate – ameenulla0007 Feb 24 '16 at 17:58
  • ... and `Cookies` is what? I'm assuming it's a class that you or a 3rd party has created. And as you have not added a `php` or `node-js` tag on the question, you will likely actually be attempting to use `localStorage` on the client: Take a read of this https://developer.mozilla.org/en/docs/Web/API/Window/localStorage – ann0nC0d3r Feb 24 '16 at 18:07
  • Are you using js-cookie (https://github.com/js-cookie/js-cookie)? If so, looks right to me. https://jsfiddle.net/simpsond/c3g28cmo/ – Dustin Simpson Feb 24 '16 at 18:15

1 Answers1

-1

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

var a = document.cookie; 
document.write();
Dharman
  • 30,962
  • 25
  • 85
  • 135
barun kumar
  • 11
  • 1
  • 1