Tags
,
Asked 30+ days ago
3 Jul 2017
Views 213
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 ?
Mitul Dabhi

Mitul Dabhi
answered Jan 22 '18 20:17

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
Edit Answer
Share
ravi

ravi
answered Jan 22 '18 20:17

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'];
}
}
Edit Answer
Share
Post Answer