I am having some cookie issues.
Things were working fine, and then we did a website update, I enabled security on the cookies, and now the remember me cookie doesn't work any more.
I'm not sure if I have some cookies that are being set in one level and not another, and I wanted to clear all my cookies to start out fresh.
Here's my clear script: (based on this answer: https://stackoverflow.com/a/2310591/356438)
<pre>
<?
echo "Before \n\n";
print_r(explode(";",$_SERVER['HTTP_COOKIE']));
// unset cookies
if (isset($_SERVER['HTTP_COOKIE'])) {
$cookies = explode(';', $_SERVER['HTTP_COOKIE']);
foreach($cookies as $cookie) {
$parts = explode('=', $cookie);
$name = trim($parts[0]);
setcookie($name, '', 1);
setcookie($name, '', 1, '/');
}
}
echo "\n\n After \n\n";
print_r(explode(";",$_SERVER['HTTP_COOKIE']));
?>
</pre>
When I run it on the site root I get this output:
Before
Array
(
[0] => Test=test
[1] => Test2=test2
[2] => lastvisit=1468329822
[3] => lastvisit=1472134053
[4] => __utma=210079566.190815705.1466193830.1472067428.1472133823.168
[5] => __utmc=210079566
[6] => __utmz=210079566.1469538895.71.3.utmcsr=website.com|utmccn=(referral)|utmcmd=referral|utmcct=/
[7] => logname=AndyD273
[8] => logid=8d3f09f7fc83eb0592f3d24d332ca85d
)
After
Array
(
[0] => Test=test
[1] => Test2=test2
[2] => lastvisit=1468329822
[3] => lastvisit=1472134053
[4] => __utma=210079566.190815705.1466193830.1472067428.1472133823.168
[5] => __utmc=210079566
[6] => __utmz=210079566.1469538895.71.3.utmcsr=website.com|utmccn=(referral)|utmcmd=referral|utmcct=/
[7] => logname=AndyD273
[8] => logid=8d3f09f7fc83eb0592f3d24d332ca85d
)
And when it run it in the directory with the members area I get this:
Before
Array
(
[0] => lastvisit=1466790329
[1] => Test=test
[2] => Test2=test2
[3] => lastvisit=1468329822
[4] => lastvisit=1472134053
[5] => __utma=210079566.190815705.1466193830.1472067428.1472133823.168
[6] => __utmc=210079566
[7] => __utmz=210079566.1469538895.71.3.utmcsr=website.com|utmccn=(referral)|utmcmd=referral|utmcct=/
[8] => logname=AndyD273
[9] => logid=8d3f09f7fc83eb0592f3d24d332ca85d
)
After
Array
(
[0] => lastvisit=1466790329
[1] => Test=test
[2] => Test2=test2
[3] => lastvisit=1468329822
[4] => lastvisit=1472134053
[5] => __utma=210079566.190815705.1466193830.1472067428.1472133823.168
[6] => __utmc=210079566
[7] => __utmz=210079566.1469538895.71.3.utmcsr=website.com|utmccn=(referral)|utmcmd=referral|utmcct=/
[8] => logname=AndyD273
[9] => logid=8d3f09f7fc83eb0592f3d24d332ca85d
)
I am setting the cookies with this, in case this isn't the right way to do it:
<?
setcookie("logname", $username, time()+(60*60*24*100), "/", ".website.com", true, true);
?>
I would love to have a way to see all the cookies and what paths they are being set at so I can make sure I'm doing it right.
Edit:
I added the domain section:
setcookie($name, '', 1, '/', '.website.com');
and cleared it down to this:
Array
(
[0] => lastvisit=1466790329
[1] => Test=test
[2] => Test2=test2
[3] => lastvisit=1468329822
)