ninedoors Posted June 12, 2008 Share Posted June 12, 2008 I'm not sure what is going on in my script but php "seems" to be reading the >= sign as <=. I'm using it with a login script. Here's it is: <?php session_start(); // Starts the session. $ul = $_SESSION['admin']; if ($ul <= 5) { header("Location: index.php"); // Goes to login page. exit(); // Stops the rest of the script. } ?> I have checked that $_SESSION['admin'] is set and it is. $ul = userlevel. I have this at the top of my page called home.php. Basically I only want users that have a userlevel of > 5 to be able to access the page. I try to log in with $_SESSION['admin'] = 9 and it sends me to index.php which isn't right. When I switch the if statement to <?php if ($ul >= 5) ?> it allows me to see the page. Anyone have any ideas. Just so you know I have echoed $_SESSION['admin'] on this page and it was equal to 9. Thanks Link to comment https://forums.phpfreaks.com/topic/109911-solved-wierd-one-here/ Share on other sites More sharing options...
rhodesa Posted June 12, 2008 Share Posted June 12, 2008 if you use this, what happens: <?php session_start(); // Starts the session. $ul = $_SESSION['admin']; if ($ul <= 5) { die("Not good enough: ".var_export($ul,true)); // header("Location: index.php"); // Goes to login page. // exit(); // Stops the rest of the script. } ?> Link to comment https://forums.phpfreaks.com/topic/109911-solved-wierd-one-here/#findComment-563987 Share on other sites More sharing options...
ninedoors Posted June 12, 2008 Author Share Posted June 12, 2008 I get this Not good enough: NULL hmmmmm, what's that mean? Session doesn't set? Link to comment https://forums.phpfreaks.com/topic/109911-solved-wierd-one-here/#findComment-563990 Share on other sites More sharing options...
thebadbad Posted June 12, 2008 Share Posted June 12, 2008 Yes, means the session isn't set. Link to comment https://forums.phpfreaks.com/topic/109911-solved-wierd-one-here/#findComment-564002 Share on other sites More sharing options...
ninedoors Posted June 12, 2008 Author Share Posted June 12, 2008 Will this set the session? $_SESSION['admin'] = some number; Or is there more to it? Link to comment https://forums.phpfreaks.com/topic/109911-solved-wierd-one-here/#findComment-564004 Share on other sites More sharing options...
thebadbad Posted June 12, 2008 Share Posted June 12, 2008 It will, just remember session_start(). Link to comment https://forums.phpfreaks.com/topic/109911-solved-wierd-one-here/#findComment-564009 Share on other sites More sharing options...
ninedoors Posted June 12, 2008 Author Share Posted June 12, 2008 WOW, I'm an idiot that was it. I thought I had it at the top of page but didn't. Thanks thebadbad Link to comment https://forums.phpfreaks.com/topic/109911-solved-wierd-one-here/#findComment-564011 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.