Web Analytics Made Easy -
StatCounter js Cookies, general question - CodingForum

Announcement

Collapse
No announcement yet.

js Cookies, general question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • js Cookies, general question

    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.

  • #2
    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
    Be yourself. No one else is as qualified.

    Comment


    • #3
      Originally posted by Old Pedant View Post
      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

      Comment

      Working...
      X