SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    Born to Code rainadaman's Avatar
    Join Date
    Feb 2005
    Location
    india
    Posts
    793
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question cookie-> path & domain?

    hi to all,

    can someone pls explain me path and domain setting in cookies.
    i tried it from book and other sources but that could not clear the point.

  2. #2
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    That path setting defines from which folder the cookie is available. For example, if you set it to /foo, it will be available in the folder called foo (which in this case is located in the root folder of the site) and any subfolders of foo. The domain setting defines which domain the cookie can be accessed from.
    ERIK RIKLUND :: Yes, I've been gone quite a while.

  3. #3
    Born to Code rainadaman's Avatar
    Join Date
    Feb 2005
    Location
    india
    Posts
    793
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    somewat getting .......?)

  4. #4
    Born to Code rainadaman's Avatar
    Join Date
    Feb 2005
    Location
    india
    Posts
    793
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    can someone pls give me some working example, so that it becomes more clear to me.

  5. #5
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    This cookie will be available from the domain foobar.org and all of it's subdomains.

    PHP Code:
    // the cookie will expire in one hour (3600 seconds)
    setcookie('name''value'time()+3600'/''.foobar.org'); 
    This cookie will be available from foobar.org/foo and all it's subdirectories.

    PHP Code:
    // the cookie will expire in one hour (3600 seconds) 
    setcookie('name''value'time()+3600'/foo''foobar.org'); 
    ERIK RIKLUND :: Yes, I've been gone quite a while.

  6. #6
    Born to Code rainadaman's Avatar
    Join Date
    Feb 2005
    Location
    india
    Posts
    793
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    wat actually subdirectories and subdomain means here.

  7. #7
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Subdomain: this-is-a-subdomain.domain.com
    Subdirectory: /folder/this-is-a-subdirectory

    Does this make it more clear?
    ERIK RIKLUND :: Yes, I've been gone quite a while.

  8. #8
    Born to Code rainadaman's Avatar
    Join Date
    Feb 2005
    Location
    india
    Posts
    793
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i know wat u r saying but, i m unable to link it with cookies....
    I m out of my mind now . ....
    this is becoming fuzzy to me.

  9. #9
    SitePoint Addict DA Master's Avatar
    Join Date
    Apr 2004
    Location
    /etc/php.ini
    Posts
    398
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you specify a domain when setting a cookie you can make it available on the whole site or in one certain sub domains.

    This could be useful for an admin cp on a site for example, an admin logs in and the cp cookie is set to work only on admin.domain.com

  10. #10
    Born to Code rainadaman's Avatar
    Join Date
    Feb 2005
    Location
    india
    Posts
    793
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah,
    now i m getting it.
    wat bout subdirectory......

  11. #11
    SitePoint Addict DA Master's Avatar
    Join Date
    Apr 2004
    Location
    /etc/php.ini
    Posts
    398
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rainadaman
    yeah,
    now i m getting it.
    wat bout subdirectory......
    Exactly the same except with directories not sub-domains, although all a sub domain is really is a directory.


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
  •