Is there a way to run a PHP FUNCTION \"fun();\" only once when a logged in user accesses a page multiple times?
here is the function.
Using authentication/sessions and storing the number of times a user has accessed that page in say a database for example or a flat file. You'll need to persist their access count to that page regardless.
Can you not run the function, then store a $_SESSION
variable? For example:
if (!isset($_SESSION['function_ran']) || $_SESSION['function_ran'] != '1') {
fun(); // run function
$_SESSION['function_ran'] = '1';
}
if(!isset($_SESSION['visitedOnce'])){
fun();
$_SESSION['visitedOnce'] = true;
}