Good day,
I'm having some trouble with a simple login system I've been piecing together. It works flawlessly in Firefox and Chrome, but for the life of me I can't seem to end the session in IE10 on Windows 8.
Here is the code I am using for the logout. I've tried a few variations here, nothing seems to work.
<?
session_start();
include("database.php");
include("login.php");
//deletes cookies by setting the time in the past, negative to what was done while creating the cookie
if(isset($_COOKIE['cookname']) && isset($_COOKIE['cookpass'])){
setcookie("cookname", "", time()-60*60*24*100, "/");
setcookie("cookpass", "", time()-60*60*24*100, "/");
}
?>
<html>
<title>Logging Out</title>
<body>
<?
if(!$logged_in){
echo "You are not currently logged in, logout failed. Please click <a href='http://www.website.ca/admin'>here</a> to login.";
}
else{
//Kill session variables (could use some work)
unset($_SESSION['username']);
unset($_SESSION['password']);
$_SESSION = array(); // reset session array
unset($_SESSION); //new code to unset session array
session_destroy(); // destroy session.
echo "You have successfully <b>logged out</b>. You will be automatically redirected.";
echo '<script type="text/JavaScript">setTimeout("location.href = \'http://www.website.ca/admin\';",2000);</script>';
}
?>
</body>
</html>
Here is the code I'm using to authenticate the pages, I'm putting this as the first lines in all the pages I want to password protect:
<?
//includes
session_start();
include("database.php");
include("login.php");
//chcek if logged in
if (!$logged_in){
die("You must be logged in to view this page. Click <a href='http://www.website.ca/admin'>here</a> to login.");
} else {
}
?>
Any ideas?
I'm getting the following errors:
Warning: Unknown: open(/var/php_sessions/sess_7a91f7a2f211673ba26734a04f96586b, O_RDWR) failed: No such file or directory (2) in Unknown on line 0 Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/php_sessions) in Unknown on line 0