blink359 Posted November 22, 2010 Share Posted November 22, 2010 Hi there i have made a mistake setting or checking my sessions and was not sure what it is because i cant reach my locked content Creating: session_start(); if ($role="valiant") { $_SESSION["username"] =="valiant"; header("location: 1/index.php"); }elseif($role="vulcan") { $_SESSION["username"] =="vulcan"; header("location: 2/index.php"); }else{ echo "Wrong Username or Password"; } Checking: <?php // Inialize session session_start(); // Check, if username session is NOT set then this page will jump to login page if (!isset($_SESSION['username']) || $_SESSION['username'] != "valiant") { header("location:../index.php"); } ?> //OR <?php // Inialize session session_start(); // Check, if username session is NOT set then this page will jump to login page if (!isset($_SESSION['username']) || $_SESSION['username'] != "vulcan") { header("location:../index.php"); } ?> Any help will be great Thanks, Blink359 Link to comment https://forums.phpfreaks.com/topic/219439-creating-and-checking-session-problems/ Share on other sites More sharing options...
revraz Posted November 22, 2010 Share Posted November 22, 2010 You have your = and == mixed up if ($role=="valiant") {$_SESSION["username"] ="valiant"; header("location: 1/index.php"); }elseif($role=="vulcan") { $_SESSION["username"] ="vulcan"; Link to comment https://forums.phpfreaks.com/topic/219439-creating-and-checking-session-problems/#findComment-1137843 Share on other sites More sharing options...
blink359 Posted November 22, 2010 Author Share Posted November 22, 2010 ahh thanks very much, Blink359 Link to comment https://forums.phpfreaks.com/topic/219439-creating-and-checking-session-problems/#findComment-1137853 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.