|
Posted by Erwin Moller on 10/23/06 09:24
runner7 wrote:
> Can anyone tell me if there is a way in PHP to determine when a session
> times out on the server or how many concurrent sessions there are in
> your application?
Hi runner,
This is how PHP implements sessions:
If you use session out of the box, they use filestorage.
Every time a request to php is made that uses a session, PHP tries to
retrieve the accompanying file based on the sessionid.
If that file is too old, the session is considered gone and you'll have to
start a new one.
From your scripts point of view there is no session at all when this
happens.
In this sheme you cannot 'do something' when a session expires.
Also you cannot easily find out how many session are active, but it can be
done:
- Count the number of not stale PHP sessionfiles in the directory where PHP
stores them.
To gain more grip on sessions, you can use databasestorage of sessions.
You'll have to write your own sessionlogic, and change your the php.ini, or
use session_set(), as follows:
session.save_handler = "user"
and you'll also have to write some routines.
Read more here:
http://nl2.php.net/manual/en/ref.session.php
and for your own sessionhandler:
http://nl2.php.net/manual/en/function.session-set-save-handler.php
It also contains links to examples. Read the usercontributed notes too.
Good luck.
Regards,
Erwin Moller
Navigation:
[Reply to this message]
|