Search code examples
phpsessioncookiessetcookie

How to set Cookie one host to another host


I have domain test1.com to create cookies to another domain with path for example.edu.in

but i have try this following way but it is not working

setcookie("user_id",$user_id,0,'/login/','www.example.edu.in');

setcookie("user_id",$user_id,0,'/login/','example.edu.in');

setcookie("user_id",$user_id,0,'/login/','.example.edu.in');

Please give me solution to access this cookies in example.edu.in


Solution

  • This is absolutely impossible. Cross-origin cookie access is forbidden.

    The closest you could come would be to install a script on the target domain and then have your script direct the browser there.