Forum Moderators: coopster

Message Too Old, No Replies

cookie setting and unsetting over different paths

cookie unset isset?

         

Matthew1980

12:51 pm on Dec 31, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there,

I have an issue which I cannot seem to work out. I have a cookie that I set in one place that is visible over the entire domain, but when I try to kill the cookie when I log out from another area of the website, I cannot seem to kill it, even though the "/" path switch is set to all domain.

Folder structure:-

website_root/update/index.php (cookie set call here on successful form submission)
website_root/update/update_control/session_set.php (set cookie function in here)
website_root/index.php (main parsing file for the entire site)
website_root/session_control/cookie_monitor.php (file to kill cookie on log out)

(this code sets cookie, this part works)
// Set cookie if specified..
if(isset($_POST['update_cookie']) == "yes")
{
setcookie($control['cookie'], $control['cookie_login'], time()+60*60*24*30, "/");
}
//Return 1 so that the script can proceed without error
return(1);

(this part is part of the function which is called but the cookie still remains even though echos prove as each part is actioned)

if($log_out_status)
{
if (isset($_COOKIE[$control['cookie']]))
{
//I think the problem is how this is structured, and this is where i need the help...
setcookie($connection['cookieLogin'], "", "0", "/");
unset($_COOKIE);
}

session_unset();
session_destroy();
unset($_SESSION);

header("Location: index.php");
}

Any advice is appreciated, then I can go and celebrate new years!

MRB

HAPPY NEW YEAR TO EVERYONE!

Matthew1980

2:50 pm on Dec 31, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello Everyone,

I have just found the fault, I was somehow overwriting the $control array in another file, I have now renamed the other array and all references to it and hey presto, killed the Cookie!

Happy new year!

MRb

coopster

3:12 pm on Dec 31, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



And the same to you!

dreamcatcher

4:30 pm on Dec 31, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Glad you sorted it Matt and Happy New Year!

dc