setcookie()

the expired time may not work correctly

  1. If the client's computer clock is wrong.

  2. The client's computer clock is right, but client and server are in different time zones. So make it works at least you should make it expires 24 hours later if you want to set up the expire time and you want to make it work globally.

Am I right?

    Wrong, if you set the cookie for an hour no matter if I'm in Mexico and you're in china the cookie will be alive just one hour

      That was I thought, but check out the php.net

      setcookie function

      http://ca3.php.net/manual/en/function.setcookie.php

      the bottom of that page there are notes like this

      greg-php at elysium dot ltd dot uk
      18-Dec-2001 12:11
      As already stated above, one reason for the failure of expiration-based cookies can be an incorrect local time on the CLIENT. Two more points about this:

      1. Not all browsers suffer from the problem. Netscape doesn't, and it appears to do the sensible thing: it compares the cookie expiry time with the server's notion of the current time, and then adds the difference onto its own notion of the time for storage.

      2. Local time includes TIMEZONE. A cookie expiring at 2 p.m. GMT has already expired at 11 a.m. on the same day if the timezone is (correctly or incorrectly) set to EST. Beware users whose computers were preinstalled in another country and who have only corrected the visible clock time!

        cookies are stored by time no by clock time, when you set a cookie for an hour the cookie will alive just one hour.

        also that comment is from 18-Dec-2001 :o

        php and browsers have made a lot of fixes since then

          Write a Reply...