Home > Article > Backend Development > In laravel, subclass controllers can use session, but parent class controllers cannot.
In laravel, subclass controllers can use session, but parent class controllers cannot. How to solve it?
In laravel, subclass controllers can use session, but parent class controllers cannot. How to solve it?
Considering that the situation you described is not too detailed
Check whether the Session has a path set. The path of config/session.php
needs to be /
, or other paths. It cannot be an empty string
Laravel does have a bug under Session. If Laravel uses file as the Session engine, when requestssome pages at the same time, the SessionID will indeed be reset (set-cookie:sessionid=xxxx) because it cannot be obtained. If the situation arises, it can be solved by changing the Session engine to database or redis (requires php artisan session:table
and migrating the database)
(.env's SESSION_DRIVE
)
Please describe the problem in more detail. Laravel session has nothing to do with the controller.