Consider memcached
for semi-persistent data like this. Save the cache key in $_SESSION
, and then use it to capture cached data.
Since memcached
caches everything in memory (and is strictly a key repository), it is faster than a database. This is somewhat ideal for things like sessions, because if you lose cached data, nothing serious is lost (the user just unexpectedly logged out).
In fact, the PHP implementation of Memcache provides a session handler (see Example # 2) that can transparently handle your sessions for you, without having to make any changes to your code.
source share