Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
163
rated 0 times [  165] [ 2]  / answers: 1 / hits: 71642  / 14 Years ago, mon, january 17, 2011, 12:00:00

How should I add domain support to these functions? I want to achieve that .example.com is declared as domain, so that the cookies can be read across all subdomains of the example.com. In its current form since domain is not set, it can only be read from www.example.com


More From » setcookie

 Answers
26

Here is a link on how to share cookies amongst a domain:



https://www.thoughtco.com/javascript-by-example-2037272



It involves setting the domain attribute of the cookie string like:



document.cookie = myValue=5;path=/;domain=example.com;


This cookie should now be accessible to all sub domains of example.com like login.example.com


[#94193] Friday, January 14, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cruz

Total Points: 415
Total Questions: 98
Total Answers: 109

Location: France
Member since Thu, May 6, 2021
3 Years ago
;