views:

1321

answers:

4

I want to know if, when I make a $.post(...) with jQuery, does any cookie is sent to the server in the post request?

Thanks!

+2  A: 

Without knowing for sure I'm going to say a big fat yes because I'm in that sort of mood!

To test it, post to a page which examines the request.

Adrian Lynch
+1 for teaching a good way to figure stuff out on your own instead of just giving an answer =)
Tomas Lycken
hahaha! thats the spirit! :)
ramayac
+5  A: 

Cookies are sent with Ajax requests.

When the HTTPOnly flag is set for a cookie, this cookie is hidden from client-side scripts, but the cookie is still sent with Ajax requests.

Ayman Hourieh
Thanks for your answer
ramayac
HTTPOnly doesn't affect AJAX/HTTP requests, it only hides the cookie from the client-side script. It will still be sent to the server.
Christian Davén
@Christian - corrected, thanks.
Ayman Hourieh
+2  A: 

Using the same cookies on the client and the server is not possible when you have httpOnlyCookies switched on. There is very good reason switch this on too:

http://www.codinghorror.com/blog/archives/001167.html

Chris Simpson
+1 Thanks for that link!
MSpreij
This is incorrect. Have a look at this question for a really good explanation of HTTPOnly+AJAX: http://stackoverflow.com/questions/27972/are-httponly-cookies-a-viable-option-for-an-ajax-website
Christian Davén
+1  A: 

Using Firefox+Firebug you can see exactly what jQuery sends, and how. Useful for debugging!

MSpreij