On 15 Aug 2011, at 19:43, LAMP wrote:

> This is THE question that bothers me for a while... I always was keeping 
> session info, like user ID, organization ID, selected book ID... within 
> $_SESSION array. Main reason is to access and maintain it faster than keeping 
> them inside session table. And, also, one less mysql connection.
> Though, in last project the $_SESSION grow up to around 30, even 50 elements 
> of the array. And several people mentioned it's better to keep so big session 
> data in mysql than in $_SESSION.
> My question is pros and cons $_SESSION vs. mysql session. And, if the amount 
> of data is only reason, when is better to keep all data in $_SESSION and when 
> to store them in mysql?

1) 30-50 array elements says nothing about the size of the data. That's like 
saying you have 30-50 piece of paper and assuming that means they contain a lot 
of text. If each array element is simply a number then 30-50 is not even close 
to being big.

2) Size of data is never good reason why you'd switch your session storage from 
files to a database. The data still needs to be read and unserialised at the 
start of a request, and serialised and written back at the end. In fact, with 
larger amounts of data you may find file-based storage to be faster.


Stuart Dallas
3ft9 Ltd
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to