Best place to store large amounts of session data

I’m building an application that needs to store and re-use large amounts of data per session.

So for example, the user selects a large list of list items (say 2000 or significantly more) which have a numeric value as their key then they save that selection and go off to another page, do something else and then come back to the original page and need to load their selections into that page.

What is the quickest and most efficient way of storing and reusing that data? In a text file saved with the session id? In a temp db table? In the session data itself (db sessions so size isn’t a limit) using a serialised string or using gzcompress or gzencode?

Any advice or insight would be great!

Thank you!!!

You might could use memcached and use the session key as the storage key or look into NoSQL database solutions like [URL=“”]MongoDb if you need more persistence options.

Depends on your traffic/data size, you can use memcached, or apc, or something like that.

The session is not the place for that kind of caching, since your same search could be performed by some other user (and you want to return the same results, from the cache)

I would place that data inside a preferences or user data table inside the database. The data stored would only be the options required to build the previous page again. So if you want the person to return to the last page they were on than I would only store the page number. Than if necessary I would add a cache layer for that specific page request. However, the user preference and cache layer should really be two separate pieces. The preference layer would store user overrides for a page or options to rebuild the data. The cache layer would return data for a given set of options such as a page number. You could even add a cache to the user preferences to eliminate a trip to the database every request.