I have a page that pulls 2-3 chunks of data from sql.
these chunks are broken into about 20 different variables.
Each page you navigate to will use the same data over and over.
Question:
should i place all the variables in session variables or should i query the database on each page, re-establishing the data and variables each time.
some of the pages modify the database and subsequently the variables.
Thanks.
Yes, it would be good to have a caching mechanism. However, php’s session variables are not the best solution. You could use a caching system such as APC or MemCached, or you could simply store them into a file on the hard disk.
Reasons not to use session variables:
The scope. I bet that some of your variables may have a wider scope than a session. In other words, some of the variables may be shared between different sessions.
Eager loading. Every time you call
session_start, all the variables are going to be unserialized and loaded whether you need them or not.