本文实例讲述了php利用cookie实现自动登录的方法。分享给大家供大家参考。具体实现方法如下:
html前端页面代码如下:
<html> <head> <title>enter password</title> </head> <body> <form name="forml" method="post" action="cookiebasedpasswordlogin.php"> <table> <tr> <td colspan="2" > <div align="center"><b>please specify the password</b></div> </td> </tr> <tr>> <td> <div align="right">customer id</div> </td> <td> <input type="text" name="username"> </td> </tr> <tr> <td> <div align="right">password</div> </td> <td> <input type="password" name="password"> </td> </tr> <tr> <td colspan="2"> <center> <input type="submit" name="submit" value="login"> </center> </td> </tr> </table> </form> </body> </html>
<?php $now = getdate(); $storetime= $now["weekday"] . " " . $now["month"] ." " . $now["year"] ; $storetime.=" time : "; if ($now["hours"] < 10) { $storetime.= "0" . $now["hours"]; } else { $storetime.= $now["hours"]; } $storetime.= ":"; if ($now["minutes"]<10) { $storetime.= "0" . $now["minutes"]; } else { $storetime.= $now["minutes"]; } $storetime.= ": "; if ($now["seconds"] <10) { $storetime.= "0" . $now["seconds"]; } else { $storetime.= $now["seconds"]; } if (isset($data)) { $counter=++$data[l]; setcookie("data[0]",$storetime,time() + (60*60*24)); setcookie("data[l]", $counter,time() + (60*60*24)); setcookie("data[2]",$username,time() + (60*60*24)); echo "<b><center>hi " . $data[2] . " ! !</center></b><br>n"; echo "<b><center>last login time :" .$data[0] . "</center></b><br>n"; echo "<b><center>current date :" .$storetime. "</center></b><br>n"; echo "<b><center>page view count :" . $data[l]. "</center></b><br>n"; echo "<b><center>you have successfully logged in!</center></b>"; echo ("<b><contor>you can access this area without entering a password for the next 24 hours!</center></b>"); } else { if (isset($username) && isset($password)) { if ($password=="superpass") { $counter=0; setcookie("data[0]",$storetime,time() + (60*60*24)); setcookie("data[l]",$counter,time() + (60*60*24)); setcookie("data[2]",$username,time() + (60*60*24)); $url="location: cookieimp.php"; header($url); }else{ echo "<hl><center>invalid password!!!</center></hl>"; } } } ?>
希望本文所述对大家的PHP程序设计有所帮助。
本文向大家介绍利用php实现一周之内自动登录存储机制(cookie、session、localStorage),包括了利用php实现一周之内自动登录存储机制(cookie、session、localStorage)的使用技巧和注意事项,需要的朋友参考一下 cookie、session、localStorage这三个应该是最让程序员头疼的了,我利用简单的登录界面的username和password来
本文向大家介绍jsp cookie+session实现简易自动登录,包括了jsp cookie+session实现简易自动登录的使用技巧和注意事项,需要的朋友参考一下 本文实例为大家分享了jsp cookie+session实现简易自动登录的具体代码,供大家参考,具体内容如下 关闭浏览器只会使存储在客户端浏览器内存中的session cookie失效,不会使服务器端的session对象失效。 如果
我的基于节点的Web服务链接到外部第三方网站,该网站需要我们也拥有的用户名/密码(但与我们的Web服务的登录不相同)。为了提供无缝的用户体验,当用户单击到第三方网站的链接时,我希望使用用户名/密码自动登录,并将其直接带到外部页面的仪表板。 至少,我想用这些信息预先填充第三方登录表单,但这篇详细描述类似情况的文章并没有让我感到乐观。 我不相信第三方站点支持OAuth或现有的SSO协议。我不能使用iF
本文向大家介绍Python实现自动登录百度空间的方法,包括了Python实现自动登录百度空间的方法的使用技巧和注意事项,需要的朋友参考一下 本文实例讲述了Python实现自动登录百度空间的方法。分享给大家供大家参考,具体如下: 开发环境:Fedora12 + Python2.6.2 运行结果: 通过运行结果可以看到,登录成功了。网页自动跳转到 /zhouciming/home 更多关于Python
本文向大家介绍PHP如何获取Cookie并实现模拟登录,包括了PHP如何获取Cookie并实现模拟登录的使用技巧和注意事项,需要的朋友参考一下 一、定义Cookie存储路径 必须使用绝对路径 $cookie_jar = dirname(__FILE__)."/pic.cookie"; 二、获取Cookie 将cookie存入文件 三、模拟浏览器获取验证码 该服务器验证码有漏洞,可以自己指定 取出c
本文向大家介绍iOS UIWebView 通过 cookie 完成自动登录实例,包括了iOS UIWebView 通过 cookie 完成自动登录实例的使用技巧和注意事项,需要的朋友参考一下 1、相关介绍 iOS在UIWebView中获取的cookie的方法:NSHTTPCookieStorage * nCookies = [NSHTTPCookieStorage sharedHTTPCookie