Home>Article>Backend Development> PHP uses cookies to implement the function of web pages remembering usernames and passwords

PHP uses cookies to implement the function of web pages remembering usernames and passwords

不言
不言 Original
2018-04-27 15:12:47 2223browse

The content of this article is about PHP using cookies to realize the function of remembering user names and passwords on web pages. It has a certain reference value. Now I share it with you. Friends in need can refer to it

1. html part

   记住账号密码  
记住用户名和密码
用 户 名:
密码:
记住用户名和密码 <{if $remember ==3}> 否 <{else}> 否 <{/if}>
2.php部分
function actionRemember() { $this->name=$_COOKIE['name']; $this->password=$_COOKIE['password']; $this->remember=$_COOKIE['remember']; $this->display("$this->subpath/remember.html"); } function actionRemtest() { $remember=$_POST['remember']; $name=$_POST['name']; $password=$_POST['password']; if($remember == '3') { setcookie("name", $name, time()+3600); setcookie('password',$password,time()+3600); setcookie('remember',$remember,time()+3600); }else{ setcookie('name','',time()-3600); setcookie('password','',time()-3600); setcookie('remember','',time()-3600); } exit; }

Related recommendations:

PHP uses file_get_contents to send http requests


The above is the detailed content of PHP uses cookies to implement the function of web pages remembering usernames and passwords. For more information, please follow other related articles on the PHP Chinese website!

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