当前位置:网站首页>Laravel changed the session from file saving to database saving

Laravel changed the session from file saving to database saving

2022-07-07 16:21:00 Full stack programmer webmaster

1.laravel The default is to use file save session Of , Save in /storage/framework/sessions Next

2. Modify the configuration file config/session.php in ‘driver’ => env(‘SESSION_DRIVER’, ‘file’) take .env In the document SESSION_DRIVER The corresponding value is determined by file Change it to database, This means .env In file SESSION_DRIVER When the configuration item cannot be found , Just use file

3. stay .env The file is configured data library

4. Use the command to automatically generate and store session Data sheet for

php artisan session:table // Generate migration file After implementation /database/migrations/ Next add a new one with create_sessions_table.php The table at the end php artisan migrate // Add a new one in the database after execution sessions surface

5. The code uses session Way unchanged

Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/113198.html Link to the original text :https://javaforall.cn

原网站

版权声明
本文为[Full stack programmer webmaster]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071406057057.html