Jump to content

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

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.