denoteone Posted January 28, 2009 Share Posted January 28, 2009 what is the the snytax to compare a session varible to "yes" if($_session['all_in_na']!= 'yes'){ header("Location: index.php"); } so if the session is not equal to yes then go to index.php Link to comment https://forums.phpfreaks.com/topic/142829-solved-if-session-variable-is-equal-to/ Share on other sites More sharing options...
.josh Posted January 28, 2009 Share Posted January 28, 2009 if($_SESSION['all_in_na'] == 'yes') { // your variable equals 'yes' do something } if($_SESSION['all_in_na'] != 'yes') { // your variable does not equal 'yes' do something } Link to comment https://forums.phpfreaks.com/topic/142829-solved-if-session-variable-is-equal-to/#findComment-748710 Share on other sites More sharing options...
ilikemath2002 Posted January 28, 2009 Share Posted January 28, 2009 <?php if($_SESSION['all_in_na']!= 'yes'){ header("Location: index.php"); } else { header("Location: xxx.php"); ?> Link to comment https://forums.phpfreaks.com/topic/142829-solved-if-session-variable-is-equal-to/#findComment-748715 Share on other sites More sharing options...
.josh Posted January 28, 2009 Share Posted January 28, 2009 the problem is that the session in $_session is not capitalized. It is case sensitive, needs to be $_SESSION. Link to comment https://forums.phpfreaks.com/topic/142829-solved-if-session-variable-is-equal-to/#findComment-748716 Share on other sites More sharing options...
ilikemath2002 Posted January 28, 2009 Share Posted January 28, 2009 the problem is that the session in $_session is not capitalized. It is case sensitive, needs to be $_SESSION. Oh let me fix that. I'm just a newb who doesn't help a lot xD. Link to comment https://forums.phpfreaks.com/topic/142829-solved-if-session-variable-is-equal-to/#findComment-748719 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.