SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard
    Join Date
    Apr 2002
    Posts
    2,318
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    setting a cookie with a more specific path is fine in all js+cookie enabled browsers?

    just want to check:

    javascript used to set (not read) a cookie whose path is more specific (e.g. '/test') than the document's path which is doing the setting (e.g. from an html file in the html root directory) will work fine?

    it worked fine (that is the cookie was successfully set) in two browsers i just checked it in, an old safari and an old firefox.

    so can i expect this to work in all browsers (those which have both js and cookie capabilities both turned on)? or are there some that will not allow this?

    thanks.

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,196
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    All browsers accept cookies, its just a matter of the user allowing there browser to accept the cookie which is very rare to find someone who doesn't

  3. #3
    SitePoint Wizard
    Join Date
    Apr 2002
    Posts
    2,318
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    it's the path aspect i'm asking about though. reading a cookie whose path is /test/ from within a document whose location is / on the server is not possible -- browsers don't allow that. setting such a cookie is possible though it seems -- at least in the two browsers i tested in. is this fine/possible in all other browsers?

    thanks.

  4. #4
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,196
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Path specific cookies should work fine in all browsers, an example i found shows a path specific setcookie function

    http://techpatterns.com/downloads/ja...pt_cookies.php

  5. #5
    SitePoint Wizard
    Join Date
    Apr 2002
    Posts
    2,318
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    ok great, thanks. i imagined that some browsers might not allow you to set more specifically pathed cookies than the document doing the setting. i was surprised my browsers allowed it. i guess it's not a problem for that to happen. good. thanks.


Bookmarks

Posting Permissions

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