LamivNahdus Posted April 22, 2008 Share Posted April 22, 2008 I need to know how to make a session available for a long time using remember me logic while signing up. I used the following code. But it is not working... $CookieDomain=".example.com"; if(!isset($_COOKIE['RememberMe'])) setcookie("RememberMe","false",time()+60*60*24*102074,"/",$CookieDomain); if(isset($_POST['LogInReqUser'])) { if(isset($_POST['LogInRemBool'])) setcookie("RememberMe","true",time()+60*60*24*102074,"/",$CookieDomain); else setcookie("RememberMe","false",time()+60*60*24*102074,"/",$CookieDomain); } if(isset($_COOKIE['RememberMe']) && $_COOKIE['RememberMe']=="true") ini_set("session.cookie_lifetime", "309598393"); else ini_set("session.cookie_lifetime", "0"); ini_set("session.cookie_domain",$CookieDomain); Instead of ini_set(), i also used session_set_cookie_params() function also. but its too not working. The above code will be placed in an init.php file which will be included in all the php files and will be exectuted before any session_start() function in my site. Because i know that ini_set can used to set a php_value only for the time of script execution. Please help me... In there any other way, to implement 'remember me' Sign in... Quote Link to comment Share on other sites More sharing options...
jonsjava Posted April 22, 2008 Share Posted April 22, 2008 gc_maxlifetime sets the session lifetime, in seconds. so, to set it to 5 hours: <?php ini_set("session.gc_maxlifetime", "18000"); ?> Quote Link to comment 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.