about Deleted message

From: Date: Sat, 21 Apr 2007 13:38:49 +0000
Subject: about Deleted message
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-35235@lists.php.net to get a copy of this message
Hello Dear PHP.net Webmasters, My added topic was deleted on the server http://news.php.net/php.notes/125558 details : Subject: note 74589 added to function.setcookie From: aziz Date: Wed Apr 18 21:58:05 2007 e-mail : aziz [at] azizce [dot] com I want to know about the reason. No information send to me , e-mail,etc. What i've do wrong, what's my mistake? Thank You, Regards, Aziz (Alihan CETIN) a.k.a aziz@azizce.com Note, Topic Contents: Hi, Many peoples have problems with setcookie() on IE... this example was Tested on -------------------------------------- Apache/2.0.52 (CentOS) PHP Version 5.1.6 MS IE 6.x -------------------------------------- Now one of them resolved, i think... I wish share the hack How to fix setcookie() IE bug...? What's the algorhytm...? Example: We have this simple script <?php if ( !isset($_COOKIE['cookyname']) ) { setcookie("cookyname", "value", time()+6600, "/", ".sitename.com"); } else { echo "Created Cookie: ".$_COOKIE['cookyname']; } ?> This cookie will expire in 47 mins. How? In IE we can't create cookies for 1 hours with setcookie() function. There is a bug. We need header() or simple HTTP headers, Javascript, etc. I've test it some different ways. And see the problem, IE ignored time()+3600 expiring value. Until we're setting the value time()+3840 . This means for IE 1 minute expiring value. (and of course, I don't know why). 3840 => 1 min. (tested) 3900 => 2 min. (tested) 3960 => 3 min. (tested) 4020 => 4 min. (tested) 4080 => 5 min. (tested) ........ 6600 => 47 min. ( 6600-3780) / 60 = 47 (tested) and technicaly ; 7140('cause 2 hours(7200) works) - 3780 (IE expire 0 min.) = 3360 3360 / 60 = 56 mins. (not tested) Now we can set the expiring value for IE to 1 to 56 minutes. As You see, we lost the 4 mins. , 'cause we take it from start... 3840-3600=240 && 240 / 60 = 4 mins. And an interesting info: 3780 => means 10 sec. for IE 3600,3660,3720 are all ignored values Conclusion Simple Example : <?php if ( !isset($_COOKIE['cookyname']) ) { // if target browser was Internet Explorer if(stristr($_SERVER['HTTP_USER_AGENT'],"MSIE")) { // SET expiring value to 47 mins. setcookie("cookyname", "alihan", time()+6600, "/", ".sitename.com"); // on Other browsers exp: Firefox } else { setcookie("cookyname", "alihan", time()+2820, "/", ".sitename.com"); } } else { echo "Created Cookie: ".$_COOKIE['cookyname']; } ?> PS: There is no expiring problem with IE on Win32 based Operating Systems...

« previous php.mirrors (#35235) next »