SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: php cookies

  1. #1
    SitePoint Member
    Join Date
    May 2003
    Location
    UK
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php cookies

    Hi

    This is my problem .
    I 've created two different cookies for my needs in my domain www.mydomain.com
    setcookie('firstcookie',$value1); // I just use this only for the browser session.If the browser is closed this is no longer available.
    The second cookie is created with expiry time
    setcookie('secondcookie',$value2,time()+3600); // This cookie exist only on the folder from where it was created
    setcookie('secondcookie',$value2,time()+3600,"/"); // Here i am able to check for the cookie in all the pages from all the folders(inside www.mydomain.com)

    What i am trying to achieve is create a (browser specific)cookie in my client browser. i want to check this cookie across many different domains(from different servers).

    I know if we create a cookie on one domain we can use it on all other sub domains on the same web server. In this case for example i could get the cookies inside www.firstsub.mydomain.com, www.secondsub.mydomain.com...etc.
    But i could n't get this cookie inside other domain www.mynewdomain.com.

    so what i am trying to do is create a cookie a browser specific one and use across many domains.Is it possible and could anyone help me on this. I am very urgently need this help.

    Thanks in advance.

    svan

  2. #2
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cookie's shouldn't be used across domains, browser specific or not, but you *can* find a workaround here
    My name is Steve, and I'm a super-villian.

  3. #3
    SitePoint Member
    Join Date
    May 2003
    Location
    UK
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your reply.
    So need to pass the session id with the url
    inorder to use that as cookie value inside my domain2,domain3...etc. Is it ok to psss the session varible along with the url

    Is there any way to get the session variables used inside domain1 to domain2 and domain3...etc.

    Again thanks for your reply.

    svan

  4. #4
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, by *shouldn't* be used across domains, I'm only referring to the standards that cookies are single domain only... however you are free to do it anyway you wish, therefore you can pass the session variable along with the url.

    As for getting the variables to go... you might want to look into storing the session variables, along with id, into a database that all domains can access. Then, if a page receives a session id for one that it thinks doesn't exist, it can recreate it from the database.

    Good luck!
    My name is Steve, and I'm a super-villian.


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
  •