开发者

cookie won't delete on specific page

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开发者_Go百科/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.


setting the cookie path to '/' fixed it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜