Re: Cookies and Headers

From: Date: Wed, 12 Jul 2000 18:56:50 +0000
Subject: Re: Cookies and Headers
Groups: php.general 
Request: Send a blank email to php-general+get-6222@lists.php.net to get a copy of this message
IE can't handle Set-Cookie and Location headers in one file. What it'll do is that as soon as it sees the location header, it'll immediately go to that location and skip any other content (including the cookie header). I solved this problem by using a Refresh tag instead of Location. Set-Cookie: blah=suck Refresh: 0; index2.php The browser will read the cookie and then try to go to index2.php as soon as possible. -- On Wed, 12 Jul 2000 10:24:31 Chris Noble wrote: >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. > > >-- >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 > > Send FREE Greetings for Father's Day--or any day! Click here: http://www.whowhere.lycos.com/redirects/fathers_day.rdct

« previous php.general (#6222) next »