Home  >  Article  >  Backend Development  >  PHP 兑现登录记住密码

PHP 兑现登录记住密码

WBOY
WBOYOriginal
2016-06-13 11:19:43712browse

PHP 实现登录记住密码

form页面


用户名
密码
记住密码
用户信息"; print_r($arr); echo "";}p($_SESSION);p($_COOKIE);?><br>登录页面<p></p> <p></p> <pre name="code" class="php"><?phpfunction p($arr){ echo "<pre class="brush:php;toolbar:false">"; print_r($arr); echo "";}session_start();//p($_POST);$_SESSION['username'] = $_POST['username'];$_SESSION['password'] = $_POST['password'];if($_POST['jizhu']){ setcookie('username',$_POST['username'],time()+60); setcookie('password',$_POST['password'],time()+60); }header("location:form.php");
用户信息页面

<?phpsession_start ();echo "先关闭浏览器,在访问form.php 试试,然后 点推出在关闭浏览器试试";p($_SESSION);p($_COOKIE);if(empty($_SESSION['username'])){	if(empty($_COOKIE['username'])){		echo "<a href='form.php'>请先登录";exit;	}else{		$_SESSION['username'] = $_COOKIE['username'];	}}function p($arr){	echo "<pre class="brush:php;toolbar:false">";	print_r($arr);	echo "
";}?>2131231231修改信息推出
推出页面
<?phpsession_start ();unset($_SESSION['username']);unset($_SESSION['password']);setcookie('username','',0);setcookie('password','',0);header("location:form.php");?>

修改用户信息页面

<?phpsession_start ();if(empty($_SESSION['username'])){	echo "请先登录";}else{	echo "这里是信息";}?>



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn