Hello,
I am having problems with storing sessions on my website, I have copied the website over to a new server (windows) to do some development work but the sessions will not store I have tried this using Xampp on xp locally & on another 3rd party normal server.
The original location where it works is Linux, this is the only difference the code is identical.
Code: Select all
<?php require_once("includes/session.php5");?>
<?php require_once("includes/functionsuni.php5");?>
<?php dbConnect();?>
<?php
$forgot = $_GET["forgot"];
//update the page if the submit button has been pressed
if (isset($_POST["login"])){
$queryStatus = "<b>The email or password you provided, was invalid, please try again.</b> <br><br>";
//validate post data
$postsToCheck = array("email","password");
$postsMinLength = array(6,6);
$postsMaxLength = array(60,60);
$errors = validatePostData($postsToCheck,$postsMaxLength,$postsMinLength);
//pull in values if it validates
if (empty($errors)){
$queryStatus = "no validation errors";
$email = mysqlPrep($_POST["email"]);
$password = mysqlPrep($_POST["password"]);
$hashedPassword = sha1($password);
$query = "SELECT id, email, name FROM users
WHERE email = '{$email}'
AND hashedpassword = '{$hashedPassword}'";
$results = mysql_query($query);
if(mysql_num_rows($results) == 1 && $forgot == 1 ){
$user = mysql_fetch_array($results);
$_SESSION["id"] = $user["id"];
$_SESSION["name"] = $user["name"];
$_SESSION["email"] = $user["email"];
redirect("updatelostpassword.php5?pass=" . $password . "");}
elseif(mysql_num_rows($results) == 1){
$user = mysql_fetch_array($results);
$_SESSION["id"] = $user["id"];
$_SESSION["name"] = $user["name"];
$_SESSION["email"] = $user["email"];z
redirect("index.php5");
}else{
$queryStatus = "<br><b>The email or password you provided, was invalid, please try again.</b> <br><br>";
}
} else {
$queryStatus = "";
for ($i = 0; $i < count($errors);$i++){
$queryStatus .= $errors[$i];
}
}
}
?>
<?php include("includes/header.php5");?>
<?php require_once("includes/leftnavi.php5"); ?>
<td id="mainmiddle">
<table>
<tr>
<td class="longtableheader">
Attention
</td>
</tr>
<tr>
<td class="longtablecontent">
<?php if (!isset($_GET["forgot"])){
echo "<b>The requested section of the site requires a log in.</b><br><br>
Please log in using the form above.<br><br>";
}
?>
<br>
<font color="#CC3333"><?php echo $queryStatus;?></font>
<br>
If you have <b>lost</b> your password, please enter your email below and we will send you a link to reset your password
<br><br>
<form action="lostpassword.php5" method="post" id="login">
Email: <input type="text" name="email" size="32"value="">
<input type="submit" name="newpassword" value=">">
</form>
</td>
</tr>
</table>
</td>
<?php require_once("includes/rightnavi.php5"); ?>
<?php require_once("includes/footer.php5"); ?>
<?php dbDisconnect();?>
The check login session file session.php5
Code: Select all
session_start();
function checkLoggedin(){
if (!isset($_SESSION["id"])){
redirect("login.php5");;
}
}
function confirmLoggedIn(){
if (isset($_SESSION["id"])){
return true;
} else {
return false;
};
}
function logOut(){
$_SESSION = array();
if(isset($_COOKIE[session_name()])){
setcookie(session_name(),"",time()-42000,"/");
}
session_destroy();
redirect("index.php5");
}
I have tried using session-write-close() after setting which did not work. I stopped the script from re-directing to the index page and echoed the session variables and they are all there, they just get deleted when i switch pages? I am pulling my hair out can any one help?
Response from
Code: Select all
ini_set ("display_errors", "1");
error_reporting(E_ALL);Code: Select all
Notice: Undefined index: forgot in C:\xampp\htdocs\login.php5 on line 8