Jump to content

Automatic login


SCook

Recommended Posts

Does anyone know a good way, or a tut, for an automatic user login?  The only thing I can think of is capturing their ip and checking it upon landing on the site.  The only problem is that with some net connections, the ip will change when the modem is turned on again, or the system is restarted.  Any help would be appreciated.  Thanks.

Link to comment
https://forums.phpfreaks.com/topic/54918-automatic-login/
Share on other sites

Use cookies.

Read http://in.php.net/manual/en/function.setcookie.php

 

As per the example in the manual:

 

Use the below script to set a cookie in the user's browser. Good to use after the user authenticates his/her credentials for the first time.

<?php

$value = 'something from somewhere';

 

setcookie("TestCookie", $value, time()+60*60*24*30 );  /* expire in 30 days */

 

?>

 

On the landing page use this:

<?php

// Print an individual cookie

//echo $_COOKIE["TestCookie"];

if ($_COOKIE["TestCookie"]=="something from somewhere") {

// Write code for automatic login

} else {

  //User's browser does not have the required cookie. Do not login

}

 

?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/54918-automatic-login/#findComment-271639
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.