Reputation: 139
I am using jQuery.post()
to send data to the server, when the server sends data back to the client, the post()
callback is invoked. I know that the data which the server sends has a cookie
, and I would like to read it. In order to do so, I used document.cookie
within the callback. Printing (alerting) the document.cookie
does not hold the cookie, though using Firebug (or Chrome developer tools), the cookie appears.
Is there any way to access the cookie, which was returned by sending data to the server using jQuery.post()
?
Upvotes: 1
Views: 435
Reputation: 1038770
If the cookie is set with the HttpOnly flag you cannot read it from client scripts. Make sure that the server doesn't use this flag when setting the cookie if you ever hope to be able to read it from javascript.
Upvotes: 2