[PHP] Re: problems with cookies
>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 --- > >--- HTML code --- >} > >function two(){ >$othervar=$_COOKIE['cookiename1']; >echo $othervar; // here it doesn't work -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problems with Cookies
email me if you dont understand something about my question. I read it back to myself, and it all sounds so complicated! TIA "Georgie Casey" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Rite, a user logs in at http://localhost/employers/login.php and PHP sets a > cookie, eusername, that has his username, funnily enough. > > then he clicks on to the /employers/search.php, submits his query and clicks > on the page of http://localhost/freelancers/some_guy/index.php > > When I have a bit of PHP code at the top of /some_guy/index.php that check > if an employer is looking at this site. > if ($eusername <> ""){ > do this; > } > ?> > > But PHP keeps telling me that eusername IS equal to "" and no employer is > logged in, when they're definately is. WHY?? Has it something to do with the > scope of cookies?? Because when I check if eusername exists in a page in the > employers directory, it works fine. > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problems with cookies....
> $pav='nustatymai.php'; > if ( $nustatymaslangas == 1 ) { > setcookie("nustlangas", 1, time()+3600*24*30); > } else { > setcookie("nustlangas", 0, time()+3600*24*30); > } > if ( $nustatymaspastas == 1 ) { > setcookie("nustpastas", 1, time()+3600*24*30); > } else { > setcookie("nustpastas", 0, time()+3600*24*30); > } > if ( $jau == 1 ){ > header("Location: main.htm"); > exit; > } > > ?> > > > > > --- Pasirinkite --- > Same Window > New Window > > > > --- Choose --- > Same Window > New Window > > > Doing both SetCookie and Location header in the same script is problematic. No matter which order you pick, some browsers will do the Location before the SetCookie, and you have no Cookies set. -- WARNING [EMAIL PROTECTED] address is an endangered species -- Use [EMAIL PROTECTED] 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]