php使用cookie實(shí)現(xiàn)記住用戶名和密碼實(shí)現(xiàn)代碼
更新時(shí)間:2015年04月27日 10:22:59 投稿:junjie
這篇文章主要介紹了php使用cookie實(shí)現(xiàn)記住用戶名和密碼實(shí)現(xiàn)代碼,本文直接給出實(shí)現(xiàn)代碼,需要的朋友可以參考下
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<form id="form1" name="form1" method="post" action="check_remember.php">
<table width="300" border="1" align="center" cellpadding="0" cellspacing="0">
<thead>
<tr>
<td colspan="2" align="center"><b>記住用戶名和密碼</b></td>
</tr>
</thead>
<tr align="center">
<td>用 戶 名:</td>
<td><input type="text" value="<?php echo $_COOKIE['name'];?>" name="name"></td>
</tr>
<tr align="center">
<td>密碼:</td>
<td><input type="password" name="password" value="<?php echo $_COOKIE['password']?>"></td>
</tr>
<tr align="center">
<td>記住用戶名和密碼</td>
<td><?php if($_COOKIE['remember'] == 1){?><input type="checkbox" name="remember" value="1" checked><?php }else{($_COOKIE['remember'] == "")?><input type="checkbox" name="remember" value="1"><?php }?></td>
</tr>
<tr align="center">
<td colspan="2"><input type="submit" name="Submit" value="提交" /></td>
</tr>
</table>
</form>
check_remember.php
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
$name = $_POST['name'];
$password = $_POST['password'];
$remember = $_POST['remember'];
if($remember == 1){
setcookie('name',$name,time()+3600);
setcookie('password',$password,time()+3600);
setcookie('remember',$remember,time()+3600);
}else{
setcookie('name',$name,time()-3600);
setcookie('password',$password,time()-3600);
setcookie('remember',$remember,time()-3600);
}
echo "<a href=\"remember.php\">返回</a>";
?>
您可能感興趣的文章:
- 詳解PHP中cookie和session的區(qū)別及cookie和session用法小結(jié)
- thinkphp3.x中cookie方法的用法分析
- php通過curl添加cookie偽造登陸抓取數(shù)據(jù)的方法
- PHP基于cookie與session統(tǒng)計(jì)網(wǎng)站訪問量并輸出顯示的方法
- php使用CURL不依賴COOKIEJAR獲取COOKIE的方法
- php使用cookie實(shí)現(xiàn)記住登錄狀態(tài)
- php實(shí)現(xiàn)cookie加密的方法
- php使用cookie保存用戶登錄的用戶名實(shí)例
- php使用cookie顯示用戶上次訪問網(wǎng)站日期的方法
- PHP利用Cookie設(shè)置用戶30分鐘未操作自動(dòng)退出功能
相關(guān)文章
基于php權(quán)限分配的實(shí)現(xiàn)代碼
本篇文章介紹了,基于php權(quán)限分配的實(shí)現(xiàn)代碼。需要的朋友參考下2013-04-04
基于Zend的Config機(jī)制的應(yīng)用分析
本篇文章介紹了,基于Zend的Config機(jī)制的應(yīng)用分析。需要的朋友參考下2013-05-05
PHP的Laravel框架中使用消息隊(duì)列queue及異步隊(duì)列的方法
這篇文章主要介紹了PHP的Laravel框架中使用消息隊(duì)列queue及異步隊(duì)列的方法,針對(duì)Laravel 5.0后的版本,示例環(huán)境為L(zhǎng)inux系統(tǒng),需要的朋友可以參考下2016-03-03
Zend Framework教程之資源(Resources)用法實(shí)例詳解
這篇文章主要介紹了Zend Framework教程之資源(Resources)用法,結(jié)合實(shí)例形式詳細(xì)分析了Resources的功能,定義,使用方法與相關(guān)注意事項(xiàng),需要的朋友可以參考下2016-03-03
php getcwd與dirname(__FILE__)區(qū)別詳解
這篇文章主要介紹了php getcwd與dirname(__FILE__)區(qū)別詳解的相關(guān)資料,需要的朋友可以參考下2016-09-09
PHP抓屏函數(shù)實(shí)現(xiàn)屏幕快照代碼分享
誰(shuí)說抓圖只能用QQ、用打印屏幕,PHP也能做到,本文主要介紹PHP抓屏函數(shù)實(shí)現(xiàn)屏幕快照的方法2014-01-01

