Results 1 to 5 of 5

Thread: Cookies and Time Zones [Resolved]

  1. #1

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349

    Cookies and Time Zones [Resolved]

    I'm wanting to create a Cookie that only lasts a few hours. I was using this:
    PHP Code:
    setcookie("CookieName""Data"time()+60*60*(3+8), "/"".Domain.com"0); 
    The +8 is because my server is based in the PST timezone, however is there a better way so I can create the cookie's time based on the time the browser is using.
    Last edited by Electroman; Feb 27th, 2004 at 06:44 AM.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    The cookie will last for three hours...regardless of timezone.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Before I used the +8 and used:
    PHP Code:
    setcookie("CookieName""Data"time()+60*60*3"/"".Domain.com"0); 
    it was disapearing straight away because the expiry date was past already. on my Machine (running at GMT). Hang on I'll check this again just to make sure.....
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  4. #4
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Since a cookie is set by the browser on the machine, I'm sure it would automatically set the cookie in the computer's own timezone, unless PHP sends a timestamp for it to expire, rather than number of hours, minutes, etc.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Yeah your right, dunno what I must av done wrong before .
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

Posting Permissions

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



Click Here to Expand Forum to Full Width