Is it OK to have session_start as an include?
I have something like this:
// Session init
session_start();
function sKill() {
session_destroy();
session_unset();
header ("Location: login.php");
exit();
}
function sInt() {
header ("Location: login.php");
exit();
}
if (!(isset($_SESSION['sLogin']) && $_SESSION['sLogin'] != '')) {
sKill();
}
// Session variables
if (!isset($_SESSION['sUser'])) { sInt(); } else { $sUser =
$_SESSION['sUser'];}
if (!isset($_SESSION['sEmail'])) { sInt(); } else { $sEmail =
$_SESSION['sEmail'];}
if (!isset($_SESSION['sType'])) { sInt(); } else { $sType =
$_SESSION['sType'];}
if (!isset($_SESSION['sTime'])) { sInt(); } else { $sTime =
$_SESSION['sTime'];}
if (!isset($_REQUEST['id'])) { $id = 0; } else { $id = $_REQUEST['id'];}
// Kill the session if the ids dont match.
if ($id != $_SESSION['id']) {
sKill();
}
// Kill the session if timeout is exceeded.
if (isset($_SESSION['LAST_ACTIVITY']) && (time() -
$_SESSION['LAST_ACTIVITY'] > $sTime)) {
sKill();
}
Can I just call this session.php and include it at the beginning of each file?
--
Paul Halliday
http://www.squertproject.org/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php