I want a certain action to happen when a user has visited X pages of a site
Do I have to store the counter externally (in a txt file or db)?
I can't think of a way to set the counter to 0, then increment it each page load. The counter would always get reset to 0, or am I missing something obvious?
It would be pretty simple to just use $_SESSION data to store how many pages an individual has viewed.
$_SESSION['pageviews'] = ($_SESSION['pageviews']) ? $_SESSION['pageviews'] + 1 : 1;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With