Reputation: 160
I've found already Own SuperGlobal Variable in PHP? here it says that there is no way to somehow define/use a "server variable" that would be same for different users/sessions. But since few years has passed may be something has changed? And now such would be possible?
Basically I want to run a php script triggered by user event, but I don't want to run more often then e.g. once per 30mins. So my frst thought was keep a "server side var (that is visibles for all sessions/clients)" and if user trigger the event (e.g. open some page) check if script been running last 30 mins then just open the page, if no then before opening page e.g. purge outdated/passed things.
Yes I do understand I can do workaround with mySQL etc... but why to do workaroud if PHP would support what I need.
Thank you in advance!
Upvotes: 0
Views: 189
Reputation: 521994
A regular PHP variable cannot be persisted beyond the current execution of the script. Once a script ends, all its variables are gone. That's the basic nature of PHP; in fact it's the basic nature of all computer programs, it's just that PHP is typically always terminated very quickly. To persist data beyond a single script invocation, you have several options where to store that data:
Nothing of this has changed recently.
Upvotes: 1