开发者

Using PHP $_SESSION variable to store large amonts of data

开发者 https://www.devze.com 2023-04-13 02:56 出处:网络
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.

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.

Sho开发者_如何学JAVAuld I be worried about memory issues on a shared server?

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


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.


.. 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).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号