Can a server(example2.com) set a cookie to a client(example1.com) with domain as 'example1.com' when an api call is made from example1.com to example2.com
Asked
Active
Viewed 153 times
1 Answers
0
I don't think it is possible to set cookies from one domain to another because if this happens there will be a lot of flaw in security.
You need to get example2.com to set the cookie. If example1.com redirect the user to example2.com/setcookie.php?example3=value
The setcookie script could contain the following to set the cookie and redirect to the correct page on example2.com
<?php
setcookie('example1', $_GET['example3']);
header("Location: example2.com/landingpage.php");
?>
For more visit:
There is good discussion on similar topic.

Prabesh Gouli
- 413
- 3
- 11