Adventures in creating a cross-domain cookie storage solution
Hey Mike,
We are going to be splitting our marketing site from our members site. One will be hosted on a subdomain of ours. We will want a cookie to be available between the domains.
You good with that, dude?
Thanks!
The Boss
Lots and lots of Stackoverflow search
According to Wikipedia, cookies "are small blocks of data created by a web server while a user is browsing a website and placed on the user's computer or other device by the user’s web browser. Cookies are placed on the device used to access a website, and more than one cookie may be placed on a user’s device during a session."
Cookies are useful for storing stateful types of information such as carts, authentication status, and user preferences.
Cookies have the following structure:
Name
Value
Optional Attributes
Dumb little Vite React application
Using a cookie library to help set the cookies
How do we get this to work in dev? Localhost NEVER acts the same as a production server
Setting the domain key on the cookie will either create a host-only (accessible only on the domain that set it) or one available on subdomains
It's possible to make localhost act like a real server by updating the /etc/hosts file
Hopefully by having done this once, I won't forget or end up in Stackoverflow hell again