Keeping session info in $_SESSION or in database?
| From: | LAMP | Date: | Mon, 15 Aug 2011 18:43:26 +0000 |
| Subject: | Keeping session info in $_SESSION or in database? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-314528@lists.php.net to get a copy of this message | ||
Hi all,
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?
Thanks for any help,
LAMP