Summer Sale! All accounts are 50% off this week.

lyonio's avatar

Save some data in session to avoid db requests?

It is recommended to save some data in session to avoid on every call db requests? Sometime it can has also sensitive data..

recommended?

0 likes
2 replies
mdeorue's avatar

Store: session(['key' => $value]);

Get: session()->get('key');

Delete: session()->forget('key);

lostdreamer_nl's avatar

having sensitive data in the session does not need to be a problem if the session is kept on the server (file / db or anything)

If the queries are taking long, you should put it in the session. But be aware, the session could be in the DB itself (so still requiring a query) or file based on the server (file access is usually slower then a DB query)

Please or to participate in this conversation.