Re: problems with cookies

From: Date: Fri, 06 Sep 2002 00:48:18 +0000
Subject: Re: problems with cookies
Groups: php.general 
Request: Send a blank email to php-general+get-115378@lists.php.net to get a copy of this message
><? >setcookie("cookiename1","$domin","timeset()+1800"); You're being "quote" "happy" and using "way" too "many" "quotes" "" "" :-) $domin is a variable. You don't need to use "$domin" It won't "hurt" anything, since you're just forcing PHP to build *another* string with the same exact content in it. But it's "silly" "timeset()+1800", however, is a big problem. You're *supposed* to be giving the setcookie() function a NUMBER that represents the time that has passed. You're giving it a string. That's wrong. Also, some stupid broken IE browsers won't let you provide a time without a path. It's wrong, but it's Microsoft. So add '/' as your path argument: setcookie("cookiename1", $domin, time()+1800, '/'); >$cookiename1=$domin; >echo $cookiename1; // here it works Yes and no. You're not really seeing a Cookie "work" You're just seeing the same value you just assigned. >?> >--- HTML code --- ><? >function one(){ >?> >--- HTML code --- ><input name="domin" type="text" size="40" >maxlength="63"> >--- HTML code --- ><? >} > >function two(){ >$othervar=$_COOKIE['cookiename1']; >echo $othervar; // here it doesn't work -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#115378) next »