Jump to content

'Remember me' Sign In with session


LamivNahdus

Recommended Posts

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...

Link to comment
https://forums.phpfreaks.com/topic/102320-remember-me-sign-in-with-session/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.