How can I keep variables in the server's RAM between script executions, and even between different sessions?
Do I need to install some sort of extension, or is this built into PHP somehow?
How can I keep variables in the server's RAM between script executions, and even between different sessions?
Do I need to install some sort of extension, or is this built into PHP somehow?
There is few options:
Memcache http://memcached.org/ extension. It's RAM based storage engine.
APC APC - PHP manual apc code cache allows store variables.
If you don't want any extensions you could store your data into file (serialize, or xml format), and it will be persistent data. Slower then memory storage.
And if you want to store general data, well then there is "one-hundred-two" database engines. For example MySQL, SQLite or NOSQL MongoDB and more...
You can cache a variable in the data store using apc_store() and apc_add(), then use apc_fetch() to get their value. But I think session variables $_SESSION
would be a good option if your variables are related to only one client. If the variables are GLOBAL & are used between many clients, then using database engines would also be an option.