AUTH -> loginStatus & setExpire
| From: | James Nunnerley | Date: | Sat, 27 Jan 2007 11:39:55 +0000 |
| Subject: | AUTH -> loginStatus & setExpire | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-26423@lists.php.net to get a copy of this message | ||
I'm using the AUTH login for our intranet, and am having problems with
sessions timing out too quickly. Ideally I'd like them to last 24 hours,
which is why I'm using $login->setExpire(time()+86400); However I'm not
certain it's working.
Here's my login include.
<?php
require_once("db.php");
require_once("Auth.php");
function login_form() {
?>
<form method="post" action="/index.php" onSubmit="return true;">
<table border="0" cellpadding="2" cellspacing="0"
summary="login form"
align="center" height="100%" width="100%">
<tr>
<td align="center">
<table align="center" cellpadding="2"
cellspacing="0" border="1" bgcolor="#eeeeee">
<tr>
<td>Username:</td>
<td><input type="text"
id="username" name="username" value="" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input
type="password" id="password" name="password" /></td>
</tr>
<tr>
<td colspan="2"
align="right"><input value="Login" id="doLogin"
name="doLogin" type="submit"
/></td>
</tr>
</table>
</td>
</tr>
</table>
<input type="hidden" id="authsecret" name="authsecret"
value="" /></form>
<?php
}
$params = array(
"dsn" => $dsn,
"table" => "staff",
"usernamecol" => "username",
"passwordcol" => "password"
);
// A database is used as storage container in this example
$login = new Auth("MDB2", $params, "login_form");
// Detection, if user is logged in. Otherwise the login form
// is being displayed.
$login->start();
$login->setExpire(time()+86400);
if ($disable_auth || $login->getAuth()) {
if(isset($_GET["action"]) && $_GET["action"] ==
"logout") {
// Log user out
$login->logout();
header("Location: index.php");
exit;
}
$user_defaults = login_user_defaults();
} else {
exit;
}
?>
I've tried calling loginStatus as well, but it just comes back with an empty
Array. Can anyone advise me what I'm doing wrong, in particular whether I
can get back the loginStatus - i.e. length of current login session?
Cheers
Nunners