Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 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
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,652
    Thanks
    80
    Thanked 4,640 Times in 4,602 Posts
    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
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    cj-inc (08-21-2011)

  • #3
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote 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


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •