views:

2409

answers:

3

I want to up the time my users will stay logged into my site without getting automatically logged out after a period of inactivity. I'm tracking the logged in status using PHP sessions.

Was having trouble tracking down a definitive source for how to do this. Any ideas?

EDIT:

OH! One more thing is, I want to control this from my .htaccess file.

+4  A: 

You can't do that from the htaccess file but you can change this line in your php.ini file.

session.gc_maxlifetime = 1440

Update: it seems to be possible, so i stand corrected

php_value session.gc_maxlifetime 3600

I haven't tried this out though.

Ólafur Waage
thanks, i'll test it out and report back
Ian
so far so good, thanks
Ian
Also take into account the max cookie lifetime.
cletus
+1  A: 

You could also try changing the value at runtime.

ini_set('session.gc_maxlifetime', '3600');

http://au.php.net/manual/en/function.ini-set.php

Asciant
A: 
ini_set('session.gc_maxlifetime', '3600');

Do i have to use above code on every page or just once

bluepicaso
@harpreet bhatia, if you have a new question, please ask it. Don't post answers unless you're actually answering the question.
Michael Myers
I was asking. The '?' seems missing. sorry
bluepicaso
What I mean is, this right here is posted as an answer to the question at the top of the page -- but it isn't an answer at all. To ask a question, you need to go through that button in the upper right of the page.
Michael Myers