I have a login/password system set up in PHP to gain access to the interface for a content mamangement site.
Every page in the admin area checks for the existence of a Session variable. If it doesn't exist the user gets sent back to the login page.
Problem: The login and authentication of the session variable works properly. But if you don't continually navigate somewhere with roughly 30 seconds you the session seems to expire and sends you back to the login.
I don't have access to the config page to adjust the cache expiration value. The code works fine on my local machine but these problems occur only on the host machine.
/////////Checks password /////////////
<?php
include "common_db.inc";
//error_reporting(0);
$link_id = db_connect();
$login = $_POST["login"];
$password = $_POST["password"];
$rs = mysql_query("SELECT * FROM admin WHERE admin_login = '$login' AND admin_password = '$password'");
$query_data = mysql_fetch_array($rs);
if (!mysql_num_rows($rs)) {
//echo "failure";
session_start();
$user_status = "0";
session_register("user_sta
tus");
header("Location:login.php
?opt=fail"
);
}else {
session_start();session_de
stroy();$u
ser_status
= "iamin";session_register("
user_statu
s");$user_
level = $query_data["admin_securit
y_level"];
session_re
gister("us
er_level")
; header("Location:index.php
");
};
?>
/////Every admin page includes the following session check:
//// I attempt to set the cache expire to a large number but still experience a quick expiration of the session
<?php session_cache_expire(30000
);
session_start();
if (!isset($_SESSION["user_st
atus"])){h
eader("Loc
ation: login.php");}
elseif($_SESSION["user_sta
tus"]!="ia
min"){head
er("Locati
on: login.php");}else{}; ?>
Any thoughts would be appreciate.
Start Free Trial