Automatic authorization on the site

Good afternoon.

We go to the site with a username and password, then close the browser. We open the browser and the site again – you do not need to log in. It is clear that the browser remembered the username and password and wrote it down somewhere.

  1. What is the correct name for the above? (for further googling)
  2. Can someone suggest or give an example of the simplest remembering a login and password by a site?
    I know how to write the registration itself, here is the final touch.

Answer 1, authority 100%

All about cookies and more


Answer 2

The browser did not remember the login / password, but the session data that it recorded in the cookie. Here is a topic for further Google.


Answer 3

The default session lifetime ends after the browser is closed, you can extend this time in seconds

session_set_cookie_params(10800);

Answer 4

$is_logged=false;
if(isset($do) && $do=="do_login"){
if(isset($login) && isset($password)){
    [email protected]($password);
    $db->Query("SELECT * FROM `users` WHERE login='$login' and pass='$password'");
    if($db->RowCount()){
    $row=$db->Row();
    setcookie("user_id",$row->id,time()+28800);
    setcookie("user_password",$password,time()+28800);
    @session_register("user_id");
    @session_register("user_password");
    $_SESSION["user_id"]=$row->id;
    $_SESSION["user_password"]=$password;
    $is_logged=true;
    }
}
}elseif(intval($_SESSION["user_id"]) > 0 && $_SESSION["user_password"]){
$db->Query("SELECT * FROM `users` WHERE id=".intval($_SESSION["user_id"]));
$row=$db->Row(); 
if($_SESSION["user_password"]==$row->pass){
    $is_logged=true;
}else{
    $is_logged=false;
}
}elseif(intval($_COOKIE["user_id"] > 0)){
$db->Query("SELECT * FROM `users` WHERE id=".intval($_COOKIE["user_id"]));
$row=$db->Row();
if($_COOKIE["user_password"]==$row->pass){
    $is_logged=true;
    @session_register("user_id");
    @session_register("user_password");
    $_SESSION['user_id']=$row->id;
    $_SESSION['user_password']=$_COOKIE["user_password"];
}else{
    $is_logged=false;
}
}
if(!$is_logged){
setcookie("user_id", "", 0);
setcookie("user_password", "", 0);
$_SESSION["user_id"]=0;
$_SESSION["user_password"]="";
$smarty->display("sitelogin.tpl");
}

Here’s one solution… By the way, check out the security level.