问题
I'm running into a weird problem. I'm building an external mobile webapp that intefaces with Drupal Services. When I call the login.json service, a cookie is set (or so I think) that tells Drupal that I'm logged in.
The webapp is currently running under the same domain but in a subdirectory. But here's the tricky part. In my chrome resources browser, I can see the cookie under cookies. However, when I try to log the contents of document.cookie it comes back empty.
What I need to do is check for that cookie's existence in my JS code. But since I can't get it from document.cookie, I'm not sure what I'm missing.
Also, the cookie's expiration date is not earlier than today, and the domain matches.
Thanks in advance for all your help!
回答1:
Sounds like the cookie is HTTP only. If this is set by Drupal, you may have to modify the Drupal source code to change it if there is no setting available.
A ticket on the Drupal tracker indicates that HTTP only cookies are used starting from v6.x, as a security measure.
来源:https://stackoverflow.com/questions/6217795/cant-access-a-cookie-using-document-cookie-in-js