Expiring sessions logout

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
localhost
Forum Commoner
Posts: 43
Joined: Tue Dec 07, 2004 4:52 am
Location: islamabad
Contact:

Expiring sessions logout

Post by localhost »

how can i detect when the session has expired...and want the user to logout when the session has been expired...i have set the
session_cache_expire(30);
but do i have do this on every page before session start...
User avatar
gite_ashish
Forum Contributor
Posts: 118
Joined: Sat Aug 31, 2002 11:38 am
Location: India

Post by gite_ashish »

One general method:
- When user successfully logs in, register user's email/loginid into session, using session_register() / $_SESSION[].
- On every page you can check for registered variable isset() or not.

- You can put this session validation code in a file like header.php and require_once() it on each page. This will ease your code modification/maintenance.
Post Reply