How to Access Cookies Across Subdomains
Accessing cookies across subdomains allows you to set a single cookie up on your visitors' hard drive which any section of your site can then retrieve. Cookies are small text files which contain persistent data such as, for example, a username or the content of a shopping cart. After a site has set up a cookie, any page under the same domain can usually access that cookie. However, if your website uses subdomains, such as, for example, "example.mysite.com," you might be unable to share cookies between them. You can fix that issue by modifying the source code of the script which sets the cookie up.
Instructions
-
-
1
Open the script in a text editor such as, for example, Notepad. Typical scripting languages used to create cookies are Perl, PHP or ASP.
-
2
Find the lines of code which create a cookie on the hard drive of your website's visitors. In PHP, for example, the function which creates cookies is "setcookie()", while in ASP, it is "Response.Cookies()".
-
-
3
Place a period before your main domain. This will allow your script to share the cookie between multiple subdomains. For example, if your domain name is "mywebsite.com", the domain name you reference in the function which creates the cookie should be ".mywebsite.com", without the quotes.
-
4
Save your script.
-
1