0

I'm currently storing a fair amount of data in the $_SESSION variable. I'm doing this so I don't need to keep accessing the database.

Should I be worried about memory issues on a shared server?

Can servers cope with large amounts of data stored in the $_SESSION variable?

2 Answers 2

6

Should I be worried about memory issues on a shared server?

Yes - session data is loaded into the script's memory on every request. Hence, you are at risk of breaking the individual per-script memory limit. Even if you don't hit the limit, this is really inefficient.

Accessing data from the database on demand is much better.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you - will look into requesting data on each page request
3

.. in addition to what @Pekka wrote:

PHP sessions an not alternative to a caching solution !

You should investigate if your server has APC available. You should use that on top of layer which accesses information from database (assuming you actually have an OO code).

2 Comments

Good point, seeing as this probably is what the OP wants to do
I do have an OO approach. The data on the other hand is not necessarily for caching purposes but merely a resource for storing data which can be add to and removed from. I can easily avoid storing this in a session and instead make a db request when manipulating.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.