I know when you request a page normally it is typically the case that you would use server side session data and set cookies via HTTP headers, but does it work the same when the content is requested via AJAX?
views:
35answers:
1
+2
A:
An AJAX request contains the same request/response information as a traditional HTTP request. You can set cookies on the client once the async callback is executed, etc.
Cesar
2010-02-08 01:02:57
@Cesar I'm sorry for being dumb but can you elaborate. Are you saying, yes you can set cookies using your web server's HTTP headers like normal even during JavaScript? Or, when you say "on the client", are you saying I should set them using the client (ie, JavaScript). I want to be able to set them from the server so I can use database sessions easily, but if I can't I guess it's not the end of the world.
orokusaki
2010-02-09 15:10:23
Sorry for not being clear enough. The response you get from an async request made from JavaScript, is the same you would get if your request was not made via AJAX. In short, yes you can set cookies if your request was made with AJAX. It depends on the server side code to set response headers.
Cesar
2010-02-09 16:46:33
@Cesar Awesome. Thanks!
orokusaki
2010-02-10 02:46:08