Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a cookie for another domain using JavaScript?

Is it possible to set cookie in one domain and access the same in another domain?

Actually I need to set a cookie in A.com page when user clicks a button and then user needs to be redirected to B.com. But the cookies are working for the same domain but not for other domain.

like image 201
user241674 Avatar asked Feb 28 '26 17:02

user241674


1 Answers

No. You can only set cookies for the domain your script is currently running on.

like image 171
CoderPi Avatar answered Mar 03 '26 05:03

CoderPi