automatic log out

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
staar2
Forum Commoner
Posts: 83
Joined: Fri Apr 06, 2007 2:57 am

automatic log out

Post by staar2 »

I got login and i would like to make it log out when some time expires. I got idea to make session var and hold the time when it were set with expire time. Then make check if the time is over and take back to login page.

$_SESSION['time'] = time() + time_expires;

What solution would you use ?
User avatar
Sekka
Forum Commoner
Posts: 91
Joined: Mon Feb 18, 2008 10:25 am
Location: Huddersfield, West Yorkshire, UK

Re: automatic log out

Post by Sekka »

Sessions automatically expire after a certain amount of time, so that should log the user out for you.
staar2
Forum Commoner
Posts: 83
Joined: Fri Apr 06, 2007 2:57 am

Re: automatic log out

Post by staar2 »

hm that's true when you have access to php ini file. But most server has the session lifetime set to 0 :roll:
User avatar
Sekka
Forum Commoner
Posts: 91
Joined: Mon Feb 18, 2008 10:25 am
Location: Huddersfield, West Yorkshire, UK

Re: automatic log out

Post by Sekka »

They have the session cookie lifetime set to 0, not the session itself. It's usually about 20-30 minutes dependent on the server.
Post Reply