chelnov63 Posted May 21, 2007 Share Posted May 21, 2007 Hi what is the default Session Timeout for php...is there a way to increase this on the web server I am hostign my php scripts on.. Cheers Quote Link to comment https://forums.phpfreaks.com/topic/52313-php-session-default-timeout/ Share on other sites More sharing options...
MadTechie Posted May 21, 2007 Share Posted May 21, 2007 if you have access to the php.ini file then yes session.gc_maxlifetime = 3600 you can try <?php ini_set ( string "session.gc_maxlifetime", 3600) ?> EDIT: as a note it maybe an idea to set the session everyt time its check thus resetting the timeout Quote Link to comment https://forums.phpfreaks.com/topic/52313-php-session-default-timeout/#findComment-258077 Share on other sites More sharing options...
chelnov63 Posted May 21, 2007 Author Share Posted May 21, 2007 thanks for that..i dont have access to the ini file... can i just do <?php ini_set ( string "session.gc_maxlifetime", 3600) ?> to set it then, even if i dont have acess to the ini file? Quote Link to comment https://forums.phpfreaks.com/topic/52313-php-session-default-timeout/#findComment-258089 Share on other sites More sharing options...
MadTechie Posted May 21, 2007 Share Posted May 21, 2007 you can try.. it "Should" work but i have has limited success with it.. not many options i can think of.. if anyone has idea's i would like to hear them as well Quote Link to comment https://forums.phpfreaks.com/topic/52313-php-session-default-timeout/#findComment-258090 Share on other sites More sharing options...
jitesh Posted May 21, 2007 Share Posted May 21, 2007 The default session time out is 1440 secs (24 mnts) You can not change it from ini_set(). You need to dunamic open php.ini and need to set session.cookie_lifetime = 'Number of secs you want to set for session timeout'. and restart web server. Quote Link to comment https://forums.phpfreaks.com/topic/52313-php-session-default-timeout/#findComment-258097 Share on other sites More sharing options...
chelnov63 Posted May 21, 2007 Author Share Posted May 21, 2007 thanks for the input guys... another question along the same lines: <?php session_start(); $_SESSION['size']='large'; session_destroy(); echo "Session Size: ".$_SESSION['size']; //this echoes out Session Size: large ?> why does the above still echo out the value in $_SESSION['size'], after i have used session_destroy() ? Cheers Quote Link to comment https://forums.phpfreaks.com/topic/52313-php-session-default-timeout/#findComment-258100 Share on other sites More sharing options...
MadTechie Posted May 21, 2007 Share Posted May 21, 2007 try <?php session_start(); $_SESSION['size']='large'; unset($_SESSION); session_destroy(); session_start(); echo "Session Size: ".$_SESSION['size']; //this echoes out Session Size: large ?> If you are creating a new session, but want to make sure that there are currently no sessions active by doing session_destroy(); make sure you start the session again using session_start(); or else your session data will not register properly. Quote Link to comment https://forums.phpfreaks.com/topic/52313-php-session-default-timeout/#findComment-258103 Share on other sites More sharing options...
chelnov63 Posted May 21, 2007 Author Share Posted May 21, 2007 thanks for that it works great... but do i really need unset($_SESSION);? it seems to work simply with session_destroy() Quote Link to comment https://forums.phpfreaks.com/topic/52313-php-session-default-timeout/#findComment-258113 Share on other sites More sharing options...
jitesh Posted May 21, 2007 Share Posted May 21, 2007 <?php session_start(); $_SESSION['size']='large'; unset($_SESSION); session_unset(); session_destroy(); echo "Session Size: ".$_SESSION['size']; //this echoes out Session Size: large ?> Quote Link to comment https://forums.phpfreaks.com/topic/52313-php-session-default-timeout/#findComment-258115 Share on other sites More sharing options...
chelnov63 Posted May 21, 2007 Author Share Posted May 21, 2007 thanks...the following seems to work fine <?php session_start(); $_SESSION['loggedin'] = "true"; echo "Session Size: ".$_SESSION['loggedin']; //this echoes out Session Size: large session_unset(); session_destroy(); if(!isset($_SESSION['loggedin'])) echo "not set"; //this echoes out Session Size: large ?> what is unset($_SESSION); meant for? it works correctly without it... Quote Link to comment https://forums.phpfreaks.com/topic/52313-php-session-default-timeout/#findComment-258123 Share on other sites More sharing options...
trq Posted May 21, 2007 Share Posted May 21, 2007 Um... the syntax for ini_set would be... <?php ini_set ("session.gc_maxlifetime", "3600") ?> Not... <?php ini_set ( string "session.gc_maxlifetime", 3600) ?> Quote Link to comment https://forums.phpfreaks.com/topic/52313-php-session-default-timeout/#findComment-258126 Share on other sites More sharing options...
jitesh Posted May 21, 2007 Share Posted May 21, 2007 unset($_SESSION); is approx same as session_unset(); Quote Link to comment https://forums.phpfreaks.com/topic/52313-php-session-default-timeout/#findComment-258128 Share on other sites More sharing options...
MadTechie Posted May 21, 2007 Share Posted May 21, 2007 Owww got to try that.. if that works i owe you one Thorpe Quote Link to comment https://forums.phpfreaks.com/topic/52313-php-session-default-timeout/#findComment-258129 Share on other sites More sharing options...
chelnov63 Posted May 21, 2007 Author Share Posted May 21, 2007 cheers guys.. Thorpe will that always work reliably..do i only need to put that code in once? or each time before settign a session? thanks Quote Link to comment https://forums.phpfreaks.com/topic/52313-php-session-default-timeout/#findComment-258140 Share on other sites More sharing options...
trq Posted May 21, 2007 Share Posted May 21, 2007 Yes it will work reliably, but you will have to place it before any call to session_start(). Quote Link to comment https://forums.phpfreaks.com/topic/52313-php-session-default-timeout/#findComment-258161 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.