Answer the question
In order to leave comments, you need to log in
Why does Laravel 5.8 make repeated database queries when working with a session?
In laravel 5.8, when working with a session, two extra database queries are performed compared to laravel 5.7.
There is a reading, updating the payload and re-reading. On a fresh clean install, only one request is made in 5.7, while three are made in 5.8. Couldn't find a solution.
What is it and how to deal with it? And do you have to fight?
Answer the question
In order to leave comments, you need to log in
Answer found
In Laravel 5.8, changes were made to the Illuminate/Session/Middleware/StartSession.php proxy
The handle method was cleaned up and rewritten. After the successful configuration of the session, a call to the fourth method, saveSession, was added to the already existing calls to 3 methods, and a new comment was given.
$this->collectGarbage($session);
$this->storeCurrentUrl($request, $session);
$this->addCookieToResponse($response, $session);
// Again, if the session has been configured we will need to close out the session
// so that the attributes may be persisted to some storage medium. We will also
// add the session identifier cookie to the application response headers now.
$this->saveSession($request);
It seems that this is a mechanism for tracking (in) session activity by timeout, we read the session - if it is too old - we kill it, if it is not rotten yet - we update the time of the last active access, we refresh the session from the database.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question