I am using php 5.4
Session variables $_SESSION['name']
are used to store data so that the data can be access in any future request but is unique to a user only
Is it possible to create something similar to a session variable which is accessible to all request coming in but no matter which user it is? In other words a session variable which is not unique to users
Currently I am using a MySQL db to store temporary data but I think if this Global Session for all users
is possible, it will give some performance improvement
i want to store something very small like a 4 digit number
By default session data is serialized
and saved to a temporary file associated with the user's session, which is tracked by a cookie. You can configure session data to be saved in the database as well. This data is available via the $_SESSION
superglobal per user.
So if you follow that logic, then either store serialized
data in a file or store it in the database and to access it, it won't be a superglobal, but something almost a superglobal if you read it in as a global array such as $GLOBALS['all_peeps']
.
You can do the same with an object or static class. It's really the same as config variables that you would use for your application regardless of the user.