3

I'm trying to access cookies using client-side javascript.

On the server I'm using node.js and cookies module. I set two cookies, "UUID" and "nick".

I can read these back correctly on the server, and I can also see that they are set by looking at the stored cookies in browser prefs (I've tried with Chrome and Firefox).

However, when I try to access them on the client, I can only seem to access "UUID", not "nick". I've tried various JS cookie reading function, and also just dumping document.cookie - everything seems to indicate that the "nick" cookie is not present.

Can anyone help?

so12311
  • 4,179
  • 1
  • 29
  • 37

1 Answers1

4

Check out if the 7th parameter of the cookie is not set to TRUE(if he is, a serverside cookie is not readable via javascript)

Dr.Molle
  • 116,463
  • 16
  • 195
  • 201
  • thanks, but I don't think this is the problem. Both cookies are created in the same way, and if I look at them in firefox their setting look identical (and have Send For: Any type of connection). – so12311 Apr 05 '11 at 18:26
  • nevermind, you were right. I dug a bit more into the docs for the cookie module and by default cookies are not accessible to client-side JS. Still don't know why the difference between UUID and nick though. – so12311 Apr 05 '11 at 18:34
  • Maybe the nick-cookie was initially set sometimes somewhere else with other parameters. Try to delete the cookie and then set a new one. – Dr.Molle Apr 06 '11 at 08:34
  • This solved my problem! I'm doing an SSO project in ASP.NET. For those using HttpCookies, make sure that the HttpOnly property is set to false. – David Peterson Jan 11 '13 at 17:05