Jump to content

[SOLVED] Log in script


fesan

Recommended Posts

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!!!

Link to comment
https://forums.phpfreaks.com/topic/61860-solved-log-in-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.