Questions on size of session

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hey! Is there some sort of limit on how much one could store in a
session as far as amount of data?

Is it advisable to store a LOT of data in the session when a user logs
in to save queries to the dbase while the user is browsing the site?

Does this depend somehow on how many sessions are going on at once?

Any input would be appreciated, thanks!

Re: Questions on size of session

There is really no limit to the size of session data, but I would strongly
advise AGAINST storing large volumes of table data in a session array to
avoid reading from the database again. That is NOT what sessions ere
designed for. You should only store in the session array what is necessary
to maintain state between requests.  If other data can be read from the
database, then read it from the database. There will be little or no
difference in performance.

Tony Marston

Quoted text here. Click to load it

Re: Questions on size of session

No, it's not advisable to store a lot of data in a session. As others
have noted, it's not a idea to duplicate data from a database. Even if
you really need some sort of caching mechanism, you wouldn't store the
data in a session. The problem is that PHP rewrites the session data
for every request. And as we all know writing to disk is a rather slow

If you really need to do it, serialize the array and store it in a
separate file.

Site Timeline