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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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