脚本宝典收集整理的这篇文章主要介绍了删除PHP Cookie?,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
setcookie("username",$username,time()+3600*24*5);
我把它清除如下:
setcookie("username","",time()-60000);
HTML表单:
<?PHP session_start(); $username = NULL; $password = NULL; if(isset($_SESSION['username'])){ $username = $_COOKIE['username']; $password = $_COOKIE['password']; } ?> <html> <tITle>Login</title> <body bgcolor='#000000'> <font color="white"> <H2><div align='center'>LOGin</div></H2> <form align='center' action='login.PHP' method='POST'> Username: <input tyPE='text' name='username' value='<?$_COOKIE['username']?>'><br \> Password: <input type='password' name='password' value='<?$password?>'><br \> Remember Me <input type='checkBox' name='remember' value='rememberme'><br \> <input type='submit' value='Login'> </form> </font> </body> </html>
用于处理表单的PHP脚本:
<?PHP session_start(); $username = $_POST['username']; $password = $_POST['password']; //Hash password in a new VARiable $password2 = md5($password); require_once "/home/a7435766/public_html/scripts/dbconnect.PHP"; $query = MysqL_query("SELECT * From userstwo WHERE username = '$username' && password = '$password2'"); if((MysqL_num_rows($query)) != 0) { //Store username and password in a cookie if($_POST['remember'] == 'rememberme') { setcookie("username",time()+3600*24*5,'','.ohjustthatguy.COM'); setcookie("password",$password,time()+3600*24*2,'.ohjustthatguy.com'); } else { setcookie("username",time()-10,'.ohjustthatguy.com'); } $_SESSION['username'] = $username; header('Location: http://www.ohjustthatguy.com/uploads/uploads.html'); } else { header('Location: http://www.ohjustthatguy.com/uploads/'); } ?>
关于pastebin的原始资料来源
> http://pastebin.com/8XtqV1PP
> http://pastebin.com/7GvQ9wRa
以上是脚本宝典为你收集整理的删除PHP Cookie?全部内容,希望文章能够帮你解决删除PHP Cookie?所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。