Hello, I have PHP site with session but every 10 minuts I need to do login. How can I set the timeout of the session for longer time?
Hi, you can try this: ini_set("session.gc_maxlifetime", "3600"); Code (markup): or by .htaccess global: php_value session.gc_maxlifetime 3600 Code (markup): value is in seconds.
You can use msession-timeout http://php.net/manual/en/function.msession-timeout.php to set session timeout.
The first code doesn't work. why is that? About the second - can I add .htaccess file in specific folder or do I must use the .htaccess file in the root folder ?
If you use root folder change will be global for all files, if you use specific folder, changed settings for files in this folder only
OK, I tried both way and...nothing. The seesion still get timeout after 20 minuts...what else can I do?
Another way would be to set a cookie. When the user loads the page, verify their credentials.. and set a session based on the cookie It's a popular method. Take logging into a forum for instance.. A session could be used if just logging in, but the 'remember me' option requires cookies
Alternatively you can use php.ini You should have a .htaccess on the root of public_html if it's a shared hosting. You should save the cookies in a specific folder under public_hmtl if it's a shared hosting: http://php.net/manual/en/function.session-save-path.php
<?php if ($_SESSION['timeout'] + 10 * 60 < time()) { // session timed out } else { // session ok } ?>