Re: Cookies reprise...

From: Date: Sat, 10 Feb 2001 08:58:32 +0000
Subject: Re: Cookies reprise...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-39067@lists.php.net to get a copy of this message
You can't set a cookie and do a header("Location:") on the same page. It will work in some versions of some browsers, and not in others. -- Visit the Zend Store at http://www.zend.com/store/ Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm ----- Original Message ----- From: Matt <bean@yaysoft.com> Newsgroups: php.general Sent: Friday, February 09, 2001 9:07 AM Subject: [PHP] Cookies reprise... > At 08:12 AM 2/9/2001, you wrote: > lets see some code.. > > > Okay, for those so inclined.... > > I did say the page the cookie script was included on was rather complex. > I will say that I double checked and made sure the cookie variables weren't > overwritten in another include file. > > You can see what I mean by going to http://www.yaysoft.com (use > IE if at > all possible) and on the right side bar where it says "User Status" and has > a message saying "You are not logged in" you can click on the login link > below it. > I created an account for anyone who wants to try (everything works except > the login cookie) so you don't have to waste your time signing up with the > script, note it is case sensitive: > user name: php > password: php > after you click the login thing the cookies will be set and the page will > not view them. > > If you used IE and you navigate to c:\windows\temporary internet files or > wherever your cookies are stored, you should notice that a cookie has been > set... with the path set to the root "/" and the domain set to > "www.yaysoft.com" but the cookies will not show up in the browser. > > I have copied the script to a text file at http://www.yaysoft.com/yaylogin.txt > > And for any who want to quickly glance at it, here is the code snippet > where the cookies are set: > if ($item[0]>0) { > setcookie("ucrumb", $uname, time()+31536000, "/", > "www.yaysoft.com", 0); > setcookie("pcrumb", $pass, time()+31536000, "/", > "www.yaysoft.com", 0); > header("Location: http://www.yaysoft.com"); > } else > header("Location: $PHP_SELF?l_action=login&bad=1"); > > And here is a slice from where they are supposedly supposed to be accessed: > // Now check to see if we are currently logged in to the Yaysystem... > // First check to see if the variables plain out don't exist... > if ((!$ucrumb)||(!$pcrumb)) { > echo "You are not logged in.<br>"; > echo "<font size=\"1\">"; > echo "<br>[<a > > href=\"http://www.yaysoft.com/yaylogin.php?l_action=login\">Login</a>] > "; > echo "[<a > > href=\"http://www.yaysoft.com/yaylogin.php?l_action=new\">New</a>]"; > echo "</font>"; > // If they DO exist make sure they are a correct pair as per the database... > } else { > > However, I've outputted the contents of $ucrumb and $pcrumb once I get to > the little segment where they are supposed to be accessed and they contain > nothing, so it seems to me that they aren't being sent to the script (which > resides in the root path where the cookie is set to!) I've used HTTP > headers to set the cookies as well, and the problem still persists. > > I know this is long and boring and tedious crap, so I don't really expect > anyone to reply, BUT if any of you have the time or inclination, any > help/suggestions/advice would be greatly appreciated. > > Regards, > Matt > > > > -- > 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 >

« previous php.general (#39067) next »