how to make session timeout longer

shangyhi2000 used Ask the Experts™
hi all
my manager want me to make the session timeout expiration to be after 1 hour can any body show me how to do
it or send me a sample

thanks in advance
best of regards
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Marco GasiFreelancer
Top Expert 2010
Use set_time_limit(number_of_seconds); (

set_time_limit(0) set limit to infinite.

Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

AlexSoftware Engineer
You have to set a cookie like this...

setcookie("usrname", $_POST['username'], time()+3600);

setcookie("give_name_to_yuor_cookie", here_the_var_od_the_session for example , and here 3600 secs means that the cookie will exprire after 1hour);

Hope that helps you.
Most Valuable Expert 2011
Top Expert 2016
"set time limit()" is about PHP execution time, not session time.  There may be some simple things you can do, or there may be a combination of things you need to do.  It will depend in part on exactly what you mean about timeout expiration -- usually this refers to a timeout after a period of inactivity.  By default this time is 1440 seconds (24 minutes).  By default the session cookies last as long as any instance of the browser.  The garbage collection may occur earlier than the browser close if you have a very long browser session.

You want to start your reading here -- some of the user-contributed notes may be relevant for you:

See also these:

Most Valuable Expert 2011
Top Expert 2016

@alex_code:  Session cookie life and session garbage collection are not interlinked.  You can make a cookie last an hour, but the garbage collection will (probably, depending on other factors) destroy the session data before the hour is up.  If you set a time-specific session cookie and close your browser and then re-open the browser, it is unpredictable whether you will get the same session back.  The usual session cookie expiration is zero, meaning "end of browser" and it is best to leave it that way.



Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial