Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I share cookies across 2 domains with javascript?

I want to be able to access and set cookies between example.com and mysite.com. How do I do that?

like image 927
NullVoxPopuli Avatar asked Nov 06 '22 09:11

NullVoxPopuli


1 Answers

You cannot do that with cookies alone: they are set explicitly per-domain, and there isn't a legitimate (read: "non-exploit") way to set them for another domain.

However, if you control both servers, it may be possible to use some workarounds/hacks to achieve this, but pretty it isn't, and it may break unexpectedly (see this question; the answers there should help you to a solution).

like image 62
Piskvor left the building Avatar answered Nov 11 '22 03:11

Piskvor left the building