I have a button on my site. When a user clicks on it
it sets a cookie like this:
setcookie("check",$id, mktime (0, 0, 0, 12, 31, 2015));
But when the user goes to other pages and clicks on the button again the cookie for old page is getting replaced by the new page.
How can I set a unique cookie for each page?
I am using PHP.
I tried:
setcookie("$id",$id, mktime (0, 0, 0, 12, 31, 2015));
but it didn’t work.
How can I give it a unique name each time?
Use the 4th parameter, path.
See this reference: http://php.net/manual/en/function.setcookie.php
You should also consider setting the 5th parameter, domain: