I am having issues with session data disappearing. While I won't say it's not code related, the conditions seem that way. After logging in, I can see the session data stored in the session file in the session data store. After 3 minutes, without doing anything with the browser, the data in the session file disappears. I'm using CentOS 6.8 and PHP 5.6.0.
session_start();
if(($_REQUEST['login_btn'] || $_REQUEST['username'] || $_REQUEST['password']) && !$_SESSION['auth']) {
if(!$_REQUEST['username'] && !$_REQUEST['username']) {
header("Location: /?msg=bp");
exit();
}
if($_SESSION['auth']!=1)
{
if(!$conn)
$conn=mysql_conn();
$sql="select pid,CONCAT(fname, ' ', lname) as pname,email1,password FROM people WHERE email1 = '".addslashes(str_replace(" ","",trim($_REQUEST['username'])))."'";
$res=mysql_query($sql,$conn);
if(mysql_num_rows($res)<1) {
header("Location: /?msg=bp");
exit();
}
else {
$row=mysql_fetch_array($res);
$user=$row['email1'];
$pass=$row['password'];
if($pass != $_REQUEST['password']){
header("Location: /?msg=bp");
}
else {
$_SESSION['pid'] = $row['pid'];
$_SESSION['email'] = $user;
$_SESSION['pname'] = $row['pname'];
$_SESSION['auth'] = true;
}
}
}
}
Relevant php.ini settings:
session.save_handler = files
session.save_path = "/data/session"
session.auto_start = 0
session.cookie_lifetime = 0
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 0
session.cache_limiter = nocache
Any help would be greatly appreciated!