Alexander
Alexander

Reputation: 652

Can I set cookies in JavaScript POST-request to the external site?

Subj. More detailed:

If I have JS-code on the page, loaded from my site, can that code make POST-request to the third site and set up cookies for that request?

Or more commonly - can I set up arbitrary headers (including cookies) in the JavaScript POST-request to the third-party site?

Upvotes: 0

Views: 1240

Answers (1)

Chris P
Chris P

Reputation: 2345

For security reasons that's not possible

You can have a hidden iframe tag into your html, but you can't access the cookies that the site saves into the browser

<?php

$var=$_COOKIE['somevar'];
?>
<iframe src="http://www.someurl.com/somefile?variable=<?php echo $var?>" style="display:none" />

Upvotes: 1

Related Questions