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.

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

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法