Forum Moderators: coopster
if (!isset($_COOKIE['MyCookie'])) {
setcookie("MyCookie", 'My Info", time()+7200, "/", "", 0);
// show something once
}
else
{
// show something else
}
What this is doing - the first time I visit your page, the cookie will not be set. That is detected in the statement
if (!isset($_COOKIE['MyCookie'])), meaning if the cookie MyCookie is NOT Set then set a cookie and show
something once, otherwise show something else (or do nothing).
The cookie in this example will expire after 2 hours. If you need a longer time frame, adjust the time parameter.
If you need something permanent, condsider storing a record of the visit in a database.