fesan Posted July 26, 2007 Share Posted July 26, 2007 Hi there. I have a very simple php login script on my page. just to have some security on some pages. The login works fine, it logs in and displays the password required pages as they should. But I am adding a script that enables a menu that is invisible to normal users. but it is always shown. It seams i cant log out. I know this has worked before. Can anyone help me to find the bugs? So in the end of the login proses it makes these variables: session_start(); $_SESSION["login"] = true; $_SESSION["user"] = $usr; $_SESSION["status"] = $status; in top of my index page i have this code: session_start(); if(isset($_GET['logut'])) { $_SESSION['login'] = false; unset($_SESSION["user"]); unset($_SESSION["status"]); } and on the pages required by index.php that needs password, this code is on top: session_start(); if(empty($_SESSION['login'])) { echo "You are not logged in"; } else { ?> HTML <?php } ?> my admin menu looks like this for testing reasons: <?php if ($_SESSION['login'] = true){ if ($_SESSION["status"] = "a"){ echo "<div id='admin'>"; echo $_SESSION['login']. "<br>"; echo $_SESSION['logout']. "<br>"; echo $_SESSION['usr']. "<br>"; echo $_SESSION["status"]; echo "</div>"; } }?> The results for: login = 1 logout = usr = status = a My logout link looks like this: <a href='index.php?logut=true'>Log out</a> Thanks for any help!!! Quote Link to comment Share on other sites More sharing options...
Fadion Posted July 26, 2007 Share Posted July 26, 2007 didnt look very carefully to the code but i did notice this line: if ($_SESSION['login'] = true){ You are initializing it, not comparing. Intending to compare you must use identical operator '=='. if ($_SESSION['login'] == true){ Quote Link to comment Share on other sites More sharing options...
fesan Posted July 26, 2007 Author Share Posted July 26, 2007 Thats was quite easy..... Stupid mistake by me! It worked perfektly now! Sorry for the truble! Thank you very much!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.