AL123 Posted June 13, 2009 Share Posted June 13, 2009 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 More sharing options...
tom2oo8 Posted June 13, 2009 Share Posted June 13, 2009 have you tried just: session_destroy(); on the logout page to get rid of any settings set, also if your using a cookie login system just get rid of the cookies Link to comment https://forums.phpfreaks.com/topic/162052-staying-logged-out/#findComment-855079 Share on other sites More sharing options...
papaface Posted June 13, 2009 Share Posted June 13, 2009 I don't see any code there that actually logs the user out, or am I missing something. Try adding $_SESSION = array(); to your code. Link to comment https://forums.phpfreaks.com/topic/162052-staying-logged-out/#findComment-855082 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.