You have all been a great help every time I come on here. For those who remember me, I am really fuzzy with PHP. In fact, I barely know it!
But I have a question - I have included a code below. Basically, using a cookie, if a user has visited in the past two hours, I do not want to show the following code below for the user. It is a pop-up, so basically, I want users on their first time to see the pop-up, then every two hours consecutively.
Here is the code below, was wondering if anyone is familiar with cookie PHP coding to help? I really appreciate it in advance!
I don't see where PHP would be involved here at all. Since you're already requiring JS to be in use, just use JS' cookie capability to do this. There's no reason to let PHP become involved here at all.
I don't see where PHP would be involved here at all. Since you're already requiring JS to be in use, just use JS' cookie capability to do this. There's no reason to let PHP become involved here at all.
Again, I'm not too familiar with either. Couldn't you use an "IF" statement and go and do something like If user has visited in the last two hours, show nothing.
And if a user has, show the script above?
That's basically the only knowledge I have of PHP haha.
if ($bShowIt) { setcookie('lastShown', time(), time() + $iDuration); // do whatever you gotta do to show it printf('Show something every %d seconds', $iDuration); }
Looks like it'd do the trick. Server languages tend to limit their reliance on cookies as much as they can.
if ($bShowIt)
{
setcookie('lastShown', time(), time() + $iDuration);
// do whatever you gotta do to show it
printf('Show something every %d seconds', $iDuration);
}
Looks like it'd do the trick. Server languages tend to limit their reliance on cookies as much as they can.
Fou, thank you so much for this, it works great! The iDuration is per seconds right?