开发者

PHP Check if username is set

开发者 https://www.devze.com 2023-03-29 08:51 出处:网络
All im trying to do is see if the username is set in the cookies, ive tried isset() and empty() with no luck. Also i tried $HTTP_COOKIE_VARS[\'username\'] and $username with those functions and the ph

All im trying to do is see if the username is set in the cookies, ive tried isset() and empty() with no luck. Also i tried $HTTP_COOKIE_VARS['username'] and $username with those functions and the php does nothing no m开发者_开发百科atter if the cookie username is set or not. Web pages are fake, but i use real ones that i know work in my code.

 $HTTP_COOKIE_VARS['username'] = $username;

 if(isset($HTTP_COOKIE_VARS['username']))
 {
 header("page2.html"); 
 }

 else {
 header("page1.html"); 
 }


Try header('Location: page2.html') and header('Location: page1.html') instead.


if(isset($_COOKIE['username'])){
   header('Location: page2.html');
}else{
   header('Location: page1.html');
}


Uh...

isset($_COOKIE['username']);

Also, you're using set_cookie to define cookies, correct? (Prolly a stupid question, sorry.)

Edit: Yeah, nevermind, the "Location: " header suggestion Daniel mentioned should do the trick (and the HTTP_*_VARS are deprecated since PHP 5, but I decided not to mention that :P).

0

精彩评论

暂无评论...
验证码 换一张
取 消