I have a PHP script that has products on many pages... basically it is just paginated database results. I have an html select box with 5/10/20 as three different options, and when the user clicks on the "change" submit button, it changes the LIMIT portion of the sql query.
BUT... many customers had requested that they wanted to change that drop-down once... and have it stored in a cookie for their next visit. So, I have this to set the cookie:
setcookie("SiteNameProds[1]", "$limit", time()+2592000);
and this code is supposed to detect if that cookie was set, and if so... use that value. If not, use a default of 5.
if(isset($SiteNameProds[1]))
{
$limit=$SiteNameProds[1];
echo"Prods Cookie IS Found";
}
else
{
echo"Prods Cookie Not Found";
if (empty($limit)) {$limit=5;}
}
Yet what happens is that the first time you change the value using the select box form, the cookie is set, but you still see only 5 products on the page (the default), UNTIL you reload. The instant you visit the page with the cookie ALREADY existing, it sees the number and displays the correct products per page value.
Basically, the cookie is set when you change the number, yet the page display only changes after you reload ONCE after that...
any ideas?