Tags
PHP , Login
Asked 6 years ago
3 Jul 2017
Views 1147
Phpworker

Phpworker posted

How to implement “Remember Me” functionality on login page?

What “Remember Me” functionality for ? and how to implement it in for my website ?
ravi

ravi
answered Nov 30 '-1 00:00

one can use session also to store username and password
on success

if(is_login()){
if(isset($_REQUEST['rememberme']) &&  $_REQUEST['rememberme']==1){
		$_SESSION["username"]=$_REQUEST['username'];
		$_SESSION["password"]=$_REQUEST['password'];
}
}
Mitul Dabhi

Mitul Dabhi
answered Nov 30 '-1 00:00

you can store login info like username and password at cookie for temporary and show it to user when you have it in cookie


on first successful login , store username and password to cookie


if(login is succesfull){
if(isset($_POST['rememberme']) &&  $_POST['rememberme']==1){
		setcookie("civil_id",$_POST['civil_id'],time()+360000);
		setcookie("password",$_POST['password'],time()+360000);
}
}



on login form , show stored username and password in cookie


 <input type="text" name="username" value="<?php  if(isset($_COOKIE['username'])){ echo $_COOKIE['username']; } ?>">
 <input type="password" name="password" value="<?php  if(isset($_COOKIE['password'])){ echo $_COOKIE['password']; } ?>">


it uses cookie so beware to use it . its potential threat
Post Answer