Cookies and Headers

From: Date: Wed, 12 Jul 2000 17:24:31 +0000
Subject: Cookies and Headers
Groups: php.general 
Request: Send a blank email to php-general+get-6190@lists.php.net to get a copy of this message
I've been running into a bit of a problem with using setcookie and header Location. Seems like when ever I use the header location the cookie wont be set. But if I try and put header first it errors out saying it cant set the cookie cause something else has been sent, which it should. Is there a specific way to use these two together or am I over looking something? Here's the code snippet that I wrote: if ($saveme == "saved"): //checks for "save my login" info setcookie("cookie[md5pass]", "$md5password", time()+3600); //sets md5 password in cookie setcookie("cookie[username]", "$username", time()+3600); //sets username in cookie endif; header ("Location: http://www.domain.com"); //then sends person to protected information So basically if I change the header part to have a meta refresh html tag it will work just fine. But if I use header then it wont set cookie. Also I'm running this with latest version of php4 on a win2k server running IIS5. Viewing these pages with IE5. chris n.

« previous php.general (#6190) next »