Jump to content

Staying logged out


AL123

Recommended Posts

I'm a new coder and am having trouble keeping a user logged out, once they 'log out'

they can go forward and back and still be logged in.

 

<p><a href="../index.php?logout=1">LogOut</a></p>

That is the code I use to log out and forward to the home page.

 

If any one can help that would be great.

AL123.

 

 

 

session_start();

$dbh=new PDO('mysql:host=localhost;dbname=mnewk2740','mnewk','string');

 

function chk_lgn($lname, $pass)

{

$salt = abc;

$pass = md5($lname.$pass.$salt);

global $dbh;           

$sql = "SELECT UserId ,logname FROM tblPass WHERE logname = '$lname' AND passwd = '$pass' ";

$sth = $dbh->prepare($sql); 

$sth-> execute();

$row = $sth->fetch(PDO::FETCH_ASSOC);

return $row;

}

 

if(isset($_POST['logname']))

{

$UserArr = chk_lgn($_POST['logname'],$_POST['passwd']);

$_SESSION['iden'] = $UserArr['UserId'];

$_SESSION['logname'] = $UserArr['logname'];

}

 

if($_POST && $_SESSION['iden'] !=0)   

header("Location:../UserPage/index.php"); 

}

 

elseif($_POST && $_SESSION['iden'] == 0)

{

echo "Try Again.";

}

Link to comment
https://forums.phpfreaks.com/topic/162052-staying-logged-out/
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.