My question is the following: I have a pair of buttons in my site, and once I click one of the buttons, it's going to set a cookie using setcookie();
. Now that a cookie is set, the user decides to click the other button, which sets a new cookie BUT it has the same cookie name as the cookie the user set earlier - Now it has a different value though.
Will the second clicked button change the value of the first set cookie? This is all I need to know.
Thanks.
if (!isset($_COOKIE['imgit_style']))
{
if (isset($_POST['green']))
{
setcookie('imgit_style', 'green', time()+31556952);
}
else if (isset($_POST['blue']))
{
setcookie('imgit_style', 'blue', time()+31556952);
}
}
else if (isset($_COOKIE['imgit_style']))
{
echo $_COOKIE['imgit_style'];
if (isset($_POST['green']))
{
setcookie('imgit_style', 'green', time()+31556952);
$style = '';
}
else if (isset($_POST['blue']))
{
setcookie('imgit_style', 'blue', time()+31556952);
$style = '_' . $_COOKIE['imgit_style'];
}
}
This is my code, and the last else if statement is not changing my cookie value to "blue", it stays green.