Re: Cookie Expire Problem

From: Date: Sun, 08 Apr 2001 04:26:55 +0000
Subject: Re: Cookie Expire Problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-47622@lists.php.net to get a copy of this message
actually, the offending line is: $cookie_expire = "$time*3"; it may be set too high if you triple it, but i think what might be happening is that it's setting $cookie_expire to '986703865*3' which would be invalid. if this is the case (i dont think you can multiply inside of quotes), then this is caused by bad programming style. Better is to only quote when dealing with strings... if you know it's math, then leave the quotes at home. solution: $cookie_expire = time() + 86000*365*10; (86000 = number of seconds in the day, times 365 days, times 10 years). Order of operations will multiply before adding. bada-bing, bada-boom. -j PS: hi everyone out there in php land, i'm new on the list, but you might know me from eyearcee. At 12:15 AM 4/8/2001, Plutarck wrote:
The problem is that it is too far in the future. Your cookie is set to expire in the year 2280. You think that's a little overkill? And it runs into the UNIX-style Y2K problem which is...um...13 years from now? Well anyway... Make your cookie's expire time a little more reasonable. Like 5 years from now, which is this many seconds: 157680000 So set it to time()+157680000 If someone has your cookie on their machine in the year 2280 and gets pissed that their login failed when it shouldn't of, don't worry about it. You'll be dead, too feeble to care, or a god for creating an application that still works after 270 years ;P -- Plutarck Should be working on something... ...but forgot what it was. ""Jeff Oien"" <jeff@webdesigns1.com> wrote in message news:NDBBJKNCILKDCEGAJBAOEEBLDLAA.jeff@webdesigns1.com... This code won't set a cookie. I took the time part from a past post to set the time for waaaay ahead. I must be doing it wrong though: $time = time(); $cookie_name = "auth"; $cookie_value = "ok"; $cookie_expire = "$time*3"; $cookie_domain = ""; setcookie($cookie_name, $cookie_value, $cookie_expire, "/" , $cookie_domain, 0); Thanks. Jeff Oien -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net
----------------------------------------------
sneak@datavibe.net      -           0x514DB5CB
he who lives these words shall not taste death becoming nothing yeah yeah forever liquid cool

« previous php.general (#47622) next »