欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

php cookie用户登录的详解及实例代码

程序员文章站 2024-03-06 11:06:13
php cookie用户登录的实现 html源码: php cookie用...</div> <div class="content"> <p><strong>php cookie用户登录的实现</strong></p> <p>html源码:</p> <div class="jb51code"> <pre class="brush: php;"> <html> <head> <title>php cookie用户登录的实现</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> </pre> </div> <p>php源码:</p> <div class="jb51code"> <pre class="brush: php;"> <?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>"; } } } ?> </pre> </div> <p>感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!</p> </div> <div class="info-pre-next"> <p> 上一篇: <a href="/article/2534441.html"> MongoDB数据库操作增删查改函数包装 </a> </p> <p> 下一篇: <a href="/article/2534443.html"> 收集学习asp.net比较完整的面向对象开发流程 </a> </p> </div> <div class="wz_tuijian"> <p> 推荐阅读 </p> <ul> <li> <a href="/article/2534442.html" target="_blank" title="php cookie用户登录的详解及实例代码"> <h2> php cookie用户登录的详解及实例代码 </h2> </a> </li> <li> <a href="/article/2534108.html" target="_blank" title="Java 读取外部资源的方法详解及实例代码"> <h2> Java 读取外部资源的方法详解及实例代码 </h2> </a> </li> <li> <a href="/article/2534058.html" target="_blank" title="Java泛型映射不同的值类型详解及实例代码"> <h2> Java泛型映射不同的值类型详解及实例代码 </h2> </a> </li> <li> <a href="/article/2533381.html" target="_blank" title="PHP单例模式详解及实例代码"> <h2> PHP单例模式详解及实例代码 </h2> </a> </li> <li> <a href="/article/2533062.html" target="_blank" title="php+ajax+json 详解及实例代码"> <h2> php+ajax+json 详解及实例代码 </h2> </a> </li> <li> <a href="/article/2531883.html" target="_blank" title="Java Process类的详解及实例代码"> <h2> Java Process类的详解及实例代码 </h2> </a> </li> <li> <a href="/article/2531601.html" target="_blank" title="php 魔术常量详解及实例代码"> <h2> php 魔术常量详解及实例代码 </h2> </a> </li> <li> <a href="/article/2531369.html" target="_blank" title="java 嵌套类的详解及实例代码"> <h2> java 嵌套类的详解及实例代码 </h2> </a> </li> <li> <a href="/article/2531320.html" target="_blank" title="Java中的Static class详解及实例代码"> <h2> Java中的Static class详解及实例代码 </h2> </a> </li> <li> <a href="/article/2531061.html" target="_blank" title="Java 异常的栈轨迹(Stack Trace)详解及实例代码"> <h2> Java 异常的栈轨迹(Stack Trace)详解及实例代码 </h2> </a> </li> </ul> </div> </article> </div> </main> <footer><div class="box"><div class="ft_nav"><div class="ft_about"><p>关于网站</p><ul><li><a href="/sitemap.xml" target="_blank" title="网站地图">网站地图</a></li><li><a href="/list/2/" title="最新程序员文章站">最新程序员文章站</a></li></ul></div><div class="ft_contact"><ul><li>本站所有数据收集于网络如有侵犯到您的权益,请联系我们进行下架处理。</li><li class="email_show"></li></ul></div></div><div class="copyright"><div class="cr_left"><p> 备案号:<a href="https://beian.miit.gov.cn/#/Integrated/index" target="_blank">粤ICP备20058927号</a></p><p>© Copyright © 2020-2022 www.superweb999.com 程序员文章站. </p></div></div></div></footer> </body> </html>