note 50957 added to function.setcookie

From: Date: Mon, 14 Mar 2005 23:36:02 +0000
Subject: note 50957 added to function.setcookie
Groups: php.notes 
Request: Send a blank email to php-notes+get-86442@lists.php.net to get a copy of this message
setcookie + header Location + IIS 5 = Trouble It took me a long time to figure out what was causing a missing cookie in one system while it worked perfectly in another... See this one: http://support.microsoft.com/kb/q176113/ In short, this WILL NEVER WORK IN IIS 5: <?php header("Pragma: no-cache"); header('Location: http://www.example.com/'); setcookie('AA','1',0,'/'); setcookie('BB','2',time() + 24 * 3600,'/'); ?> You will ONLY get the Location Header, everything else will be "cut out" by IIS 5 CGI implementation. Solutions: 1- Migrate to Apache/IIS6/Whatever 2- Use a Non Parsed Header Script (nph-*.php) 3- Try with header('Refresh: 0; $URL'); I hope this helps somebody not to spend hours knocking his/her head. Alchaemist ---- Manual Page -- http://www.php.net/manual/en/function.setcookie.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+50957 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50957&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50957&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50957&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50957&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50957&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+50957&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#86442) next »