Can headers be sent in an AJAX request?

Posted by sombe on Stack Overflow See other posts from Stack Overflow or by sombe
Published on 2010-02-18T13:51:04Z Indexed on 2010/04/17 16:03 UTC
Read the original article Hit count: 217

Filed under:
|
|
|

Can I call the server to set a new cookie with an AJAX request (that is, after the page has already loaded)?

For example, when a visitor hits a link, ajax would open a php file that sets a new cookie like this:

setcookie('cookiename', 'true', time()+3000, "/",'...');

But this is done after the html (the page containing the actual <a> tag pressed) was rendered. Is it nevertheless ok to set cookies in ajax? (maybe because the php file loaded is separate from the original html page).

© Stack Overflow or respective owner

Related posts about cookie

Related posts about header