duanjianhe1388 2017-07-31 18:49 采纳率: 100%
浏览 25

虽然路径和时间设置正确,但我无法删除PHP PHP

I have created a logout.php page to let the user sign out from the website and redirects them to the sign in page.

however what ever i do, the cookies are not getting deleted, so when the user gets redirected to the singin page the latter examines the cookies and then find it, therefore logs the user in.

Below is the code of logout.php:

<?php
unset($login);
if (isset($_COOKIE['xxx'])){
    setcookie('xxx', false, time() - 3600,"/");
}
if (isset($_COOKIE['yyy'])){
    setcookie('yyy', false, time() - 3600,"/");
}
    header("Location: singin.php");
    die();

?>

Please note that this php page is in subfolder protected by password and the html link redirects to a php file that require() the logout.php file.

  • 写回答

2条回答 默认 最新

  • duanshang7007 2017-07-31 18:52
    关注

    use php unset() to delete your cookie as, you can get the complete details here delete the cookie

    if (isset($_COOKIE['xxx'])){
        unset($_COOKIE['xxx']);
    }
    if (isset($_COOKIE['yyy'])){
        unset($_COOKIE['yyy']);
    }
    

    or, set value as null and a negative time for your cookie as

    setcookie('xxx', null, -1, '/');
    setcookie('yyy', null, -1, '/');
    

    or, set value as empty and a past time for your cookie as

    setcookie("xxx", "", time()-3600);
    setcookie("yyy", "", time()-3600);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题