dongtu1958 2011-06-30 01:51
浏览 27
已采纳

cookie不会在特定页面上删除

i am using htacess, now i noticed that i had to change the images in my header.php file (which is included in all frontend files) to http://mysite.com/images/image.gif rather than just images/image.gif for the "password-reset" page otherwise the images did not display on it, however they displayed fine on all other pages. not sure if this is relevant but it might be.

my htaccess is:

RewriteEngine on
RewriteRule ^log-in$ log-in.php
RewriteRule ^register$ register.php
RewriteRule ^password-reset$ password-reset.php
RewriteRule ^password-reset/([a-zA-Z0-9]+)$ password-reset.php?key=$1
RewriteRule ^log-out$ log-out.php

on my log-in page, and my register page, it sets the cookies and sessions once a user logs in or creates a new account. it also sets the cookies and sessions when a user resets their password via the password-reset page.

heres my cookie/session setting code used in all 3 pages:

$_SESSION['email'] = $email;
$_SESSION['password'] = $password;

if ($login_remember == 'yes')
{
    setcookie('email', $email, time() + 31536000);
    setcookie('password', $password, time() + 31536000);
}

now after i click on "log-out" and it takes me to my log out page, heres the code for that:

session_start();
session_destroy();

if (isset($_COOKIE['email']))
    setcookie('email', '', time() - 60);

if (isset($_COOKIE['password']))
    setcookie('password', '', time() - 60);

the log-out page destroys the session and sets the cookies to expire. this works fine for every page except for the "password-reset" page. the cookies are still active on the password-reset page even after i log out. i don't understand why. the cookies and sessions are only set after a form button is pushed. the code checks to see if (isset($_POST['form_submit'])) so theres no way it can be set other than to log in, register a new account, or follow their reset password link and enter a new password.

help please.

  • 写回答

1条回答 默认 最新

  • douwen1549 2011-06-30 02:28
    关注

    setting the cookie path to '/' fixed it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 求解vmware的网络模式问题 别拿AI回答
  • ¥24 EFS加密后,在同一台电脑解密出错,证书界面找不到对应指纹的证书,未备份证书,求在原电脑解密的方法,可行即采纳
  • ¥15 springboot 3.0 实现Security 6.x版本集成
  • ¥15 PHP-8.1 镜像无法用dockerfile里的CMD命令启动 只能进入容器启动,如何解决?(操作系统-ubuntu)
  • ¥30 请帮我解决一下下面六个代码
  • ¥15 关于资源监视工具的e-care有知道的嘛
  • ¥35 MIMO天线稀疏阵列排布问题
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?