Re: [Phplib-users] Session Timeout - Tracking and showing message?
Brought to you by:
nhruby,
richardarcher
|
From: Oliver Duke-W. <ol...@ge...> - 2001-11-07 13:45:19
|
On Wed, Nov 07, 2001 at 12:14:37PM +0100, Sascha Ragtschaa wrote:
> Is it possible to track, when a user has lost its session and therefore
> showing a error message like "your session has expired...". Is that possible
> with PHPlib? Does anyone have experience with such thing?
I've done that in the following manner:
i)
The function unauth() in whichever auth class you use is overridden or
modified like this:
function unauth($nobody = false) {
/*
* Add flag indicating whether session has expired
*/
if ($this->lifetime > 0 &&
((isset($this->auth["exp"]) && $this->auth["exp"])
&& (time() > $this->auth["exp"]))) {
$this->auth["expired"] = true;
} else {
$this->auth["expired"] = false;
}
$this->auth["uid"] = "";
$this->auth["perm"] = "";
$this->auth["exp"] = 0;
## Back compatibility: passing $nobody to this method is
## deprecated
if ($nobody) {
$this->auth["uid"] = "nobody";
$this->auth["perm"] = "";
$this->auth["exp"] = 0x7fffffff;
}
}
Secondly, the function auth_loginform() can now use the flag set up above.
The rest of the function will depend on what sort of auth class you use:
function auth_loginform() {
...
if (isset($this->auth["expired"]) && $this->auth['expired']) {
/*
* form to be used for sessions that have expired
*/
include($_PHPLIB["libdir"] . "crloginform_exp.html");
} else {
/*
* form to be used for new logins
*/
include($_PHPLIB["libdir"] . "crloginform.html");
}
return;
}
Thus, both users starting a new session and users trying to load a page in a
session that has expired will be forced to login, but you can use an
alternative page for expired sessions that gives more appropriate
instructions.
Cheers,
Oliver
--
Oliver Duke-Williams <ol...@ge...> Tel 0113 233 3286
Centre for Computational Geography, University of Leeds, UK
|