Web Analytics Made Easy -
StatCounter Are session cookies in JavaScript path sensitive? - CodingForum

Announcement

Collapse
No announcement yet.

Are session cookies in JavaScript path sensitive?

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

  • Are session cookies in JavaScript path sensitive?

    Hi:
    Anyone know if session only cookies are sensitive to the directory path in which they're called? I was under the impression it was only for persistent cookies. For example, lets say I call the statement:

    Code:
    document.cookie="popup=yes"
    on the root path of my site http://www.javascriptkit.com. Is that cookie now also accessible on the page http://www.javascriptkit.com/subdir?

    Someone suggested to me recently I had to use:

    Code:
    document.cookie="popunder=yes;path=/"
    in order for a session only cookie to be accessible anywhere within a site, and I thought I'd seek some clarification on this.

    Thanks,
    - George
    - JavaScript Kit- JavaScript tutorials and 400+ scripts!
    - JavaScript Reference- JavaScript reference you can relate to.

  • #2
    according to the Guide, the default for a cookie, is the direcory it was created in, and all of its subdirectories. if you want a cookie to be available throughout the entire site, then you probably ought to use ' path=/" ', even if you're creating it in the root directory.
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

    Comment


    • #3
      cookies

      Microsoft support is here to help you with Microsoft products. Find how-to articles, videos, and training for Microsoft 365, Windows, Surface, and more.


      and

      ftp://ftp.rfc-editor.org/in-notes/rfc2965.txt

      my firewall doesnt allow me to see this since its on ftp.

      What I can tell so far though, is that there isnt a standard per say for this... So the question may be moot, and one would just use what works now.

      -S. Bob

      Comment


      • #4
        The expiration date should not affect the cookie's path setting. The only difference between a "persistant" cookie and a "session" cookie is that the former has an explicit expiration date while the latter doesn't so the browser will delete it when closed.

        The cookie path defaults to the path in the URL where it's set. Using path="/" should make it available to all pages on the site no matter where you set the cookie.

        One thing to consider is the cookie domain. If your site is accessible via www.example.net, example.net and subdomain.example.net and you want to share a cookie between them, you should set the cookie domain to ".example.net".

        Comment


        • #5
          Ok thanks guys. I ask this because people had emailed me about how one of JavaScriptKit.com's popunder window script kept popping up even though the feature to pop up only once per session was on. I never inputted the path, which I guess is actually necessary.
          - George
          - JavaScript Kit- JavaScript tutorials and 400+ scripts!
          - JavaScript Reference- JavaScript reference you can relate to.

          Comment

          Working...
          X