(06-23-2021, 01:53 PM)includebeer Wrote: Craig has the right solution for your use case. You either call your function right after a successful login, or you save the state in the session data. So at the next page load, the application will "remember" is has already called this function. If you use the session, I recommend using the session() function instead of accessing a variable directly with $_SESSION['yourVariable]. This way you don't have to check if the variable exists before accessing the $_SESSION array.
Example:
PHP Code:
// get the value
$runOnce = session('runOnce');
if ($runOnce !== true) {
// run your code
some_function();
// save the value to the session data
session()->set('runOnce', true);
}
Thanks Beer. I moved the function into index.php (the one in my controller) and this seemed to take care of it since this is not connected to __construct or _init, which I know now runs on every page load. Do you think I still need to watch to see it it was already initialized?
proof that an old dog can learn new tricks