...

View Full Version : js Cookies, general question



cj-inc
08-20-2011, 10:55 PM
I create a cookie on my homepage that tracks a number, the next time they view, js calculates another number and subtracts the saved number.

Is the cookie value created accessible from a page other than the home page?

i.E. I want to create a popup window that shows the calculation but i can seem to pass the variable generated from my external js script to the internal script/page.

Am i able to call the getCookie class i created from the internal script even if the class is held in the external script or is it only accessible from the page that created the cookie?

If its a dumb question, sorry im relatively new.

Old Pedant
08-20-2011, 11:25 PM
Generally, cookies are available to any page in the *same subdomain* that created them.

But it is possible to create cookies that are accessible anywhere in the same domain (e.g., www.xyz.com vs. people.xyz.com, differing subdomains) and possible to restrict them to a single path within a subdomain (e.g., to just www.xyz.com/blog).

Most JS cookie code you see will default to setting them to a single subdomain (e.g., www.xyz.com).

Here's best summary I've found:
http://www.quirksmode.org/js/cookies.html

cj-inc
08-21-2011, 04:18 AM
Generally, cookies are available to any page in the *same subdomain* that created them.

But it is possible to create cookies that are accessible anywhere in the same domain (e.g., www.xyz.com vs. people.xyz.com, differing subdomains) and possible to restrict them to a single path within a subdomain (e.g., to just www.xyz.com/blog).

Most JS cookie code you see will default to setting them to a single subdomain (e.g., www.xyz.com).

Here's best summary I've found:
http://www.quirksmode.org/js/cookies.html

This was very helpful, a perfect explanation. Thank you very much.
i will check the path and try accessing it from the popUpWindow. Thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum