/    Sign up×
Community /Pin to ProfileBookmark

How to increase the Session timeout limit in PHP

Hi,

If there any way to increase the Session time out limit in php.

As I have a problem some page in my code takes more than 1 hr to modify, and after when I press save, it does not work.

I need to set it to 8 Hrs. Pls suggest.

Thanks
Siva

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@NogDogDec 09.2005 — I haven't tested this out, but based on my understanding, this should do the trick:
[code=php]
session_set_cookie_params(8*60*60);
session_save_path('/some/path/unique/for/this/set/of/scripts');
ini_set('session.gc_maxlifetime', '28800');
session_start();
# rest of script...
[/code]

Note: make sure the directory specified in session_save_path() is writeable by the PHP user.
Copy linkTweet thisAlerts:
@phantom007Oct 09.2008 — I haven't tested this out, but based on my understanding, this should do the trick:
[code=php]
session_set_cookie_params(8*60*60);
session_save_path('/some/path/unique/for/this/set/of/scripts');
ini_set('session.gc_maxlifetime', '28800');
session_start();
# rest of script...
[/code]

Note: make sure the directory specified in session_save_path() is writeable by the PHP user.[/QUOTE]



Hi

Question: Do we have to put the code [b]ini_set('session.gc_maxlifetime', '28800'); [/b]in all our php pages or just on the login page will do?


Thanx
Copy linkTweet thisAlerts:
@NogDogOct 09.2008 — It would need to be in each file that uses sessions if you do it that way. Of course, it would be easier to put (and the cookie setting, too), into your PHP config file (php.ini) or a local .htaccess file if allowed.
Copy linkTweet thisAlerts:
@phantom007Oct 10.2008 — ok thanx for your kind reply. ?
Copy linkTweet thisAlerts:
@huyhoang08Nov 03.2010 — i have some codes for uploading using php & party third that is flash. i try to upload with max size of 2mb to summerhost, but not work. pls help me!

i get suggest that config via .htaccess file something like this:
--------------------------------------


php_value upload_max_filesize 10M

php_value post_max_size 10M

php_value max_execution_time 300
--------------------------------------


But still not work in server

Pls, suggest me.
Copy linkTweet thisAlerts:
@vizay25687Jun 20.2012 — Hi,

Am also facing this same problem, Am trying to increase the session timeout.Please make me understand in the following code

session_save_path('/some/path/unique/for/this/set/of/scripts');

is this code really required, if yes please tell me why we need to use this code and how do we build the path.

Thanks

Vijay
Copy linkTweet thisAlerts:
@NogDogJun 20.2012 — Hi,

Am also facing this same problem, Am trying to increase the session timeout.Please make me understand in the following code

session_save_path('/some/path/unique/for/this/set/of/scripts');

is this code really required, if yes please tell me why we need to use this code and how do we build the path.

Thanks

Vijay[/QUOTE]


You only need it if other sites or pages within your site might be sharing the same PHP session data directory, in order to keep those other sites' or pages' session data clean-up times from impacting your times.
×

Success!

Help @rskshiva spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...