SCook Posted June 10, 2007 Share Posted June 10, 2007 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 More sharing options...
bonaparte Posted June 10, 2007 Share Posted June 10, 2007 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.