By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,118 Members | 1,134 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,118 IT Pros & Developers. It's quick & easy.

how to custom a session_expire

P: n/a
php version: 5.1
mysql version: 5.0
here's my problem.
i hava a MIS ...administrator's account could allocate each system
user's life-time,
it's if the user don't make any operation in this system for how many
minutes which has been allocated by administrator. the system will
automatic exit.

there's an item in the php.ini as
; Document expires after n minutes.
session.cache_expire = 180

if i have to use session to judge if system should automatic exit ,and
one of the users his account's life-time over 180...
what can i do to let the session alive...

user_login -check if id and password correct -[yes] store his id
and basic info into $_session
each time he request a operation...check if his ID is unexpired so he
can continue his operation.

hope someone can understand my poor english.

Jul 6 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On or about 7/6/2006 5:30 AM, it came to pass that bl********@gmail.com
wrote:
php version: 5.1
mysql version: 5.0
here's my problem.
i hava a MIS ...administrator's account could allocate each system
user's life-time,
it's if the user don't make any operation in this system for how many
minutes which has been allocated by administrator. the system will
automatic exit.

there's an item in the php.ini as
; Document expires after n minutes.
session.cache_expire = 180

if i have to use session to judge if system should automatic exit ,and
one of the users his account's life-time over 180...
what can i do to let the session alive...

user_login -check if id and password correct -[yes] store his id
and basic info into $_session
each time he request a operation...check if his ID is unexpired so he
can continue his operation.

hope someone can understand my poor english.
You can set the time for the Session to expire using
session_set_cookie_params, however that leaves the cookie available
after the browser exits and you must do the validation you mention.

Assuming the cookie lifetime is defaulted to the browser lifetime(it
gets deleted when the browser closes), an easier way IMHO is to set your
own timer as a session variable. Example: for a ten minute non-usage
timeout: (g
if (isset($_SESSION['$Server_time']) && (time() -
$_SESSION['$Server_time']) 600)
{
$_SESSION = array(); //break this session, clear variables
// delete session or whatever here if needed
exit;
}

$_SESSION['$Server_time'] = time(); //time in seconds
Jul 6 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.