I am now ready to use Redis to replace the original file-basedsession storage. However, after configuration, laravel still stores the session in the file. {code ...} {code ...} I am in appconfigapp. appProvidersSessionService written by myself is added to php... I am now ready to use Redis to replace the original
file-based session
Storage.
However, after configuration
laravel
Or
session
Stored in the file.
// This file is stored in the app \ Extensions directory.
Get ($ sessionId); return Redis: get ($ sessionId);} public function write ($ sessionId, $ data) {// $ redis = Redis :: connection ('default'); // $ redis-> set ($ sessionId, $ data); Redis: set ($ sessionId, $ data );} public function destroy ($ sessionId) {// $ redis = Redis: connection ('default'); // $ redis-> command ('del ', $ sessionId ); redis: command ('del ', $ sessionId);} public function gc ($ lifetime ){//}}
// The file is written in the app \ Providers directory.
Onapp\config\app.php
Added the self-writtenApp\Providers\SessionServiceProvider::class,
Go in.
And replacedapp\config\session.php
Inside'driver' => env('SESSION_DRIVER', 'redis'),
It should be called directly$request->session()->set($sessionId, $data)
Can it be stored in Redis?
Reply content:I am now ready to use Redis to replace the originalfile-based session
Storage.
However, after configurationlaravel
Orsession
Stored in the file.
// This file is stored in the app \ Extensions directory.
Get ($ sessionId); return Redis: get ($ sessionId);} public function write ($ sessionId, $ data) {// $ redis = Redis :: connection ('default'); // $ redis-> set ($ sessionId, $ data); Redis: set ($ sessionId, $ data );} public function destroy ($ sessionId) {// $ redis = Redis: connection ('default'); // $ redis-> command ('del ', $ sessionId ); redis: command ('del ', $ sessionId);} public function gc ($ lifetime ){//}}
// The file is written in the app \ Providers directory.
Onapp\config\app.php
Added the self-writtenApp\Providers\SessionServiceProvider::class,
Go in.
And replacedapp\config\session.php
Inside'driver' => env('SESSION_DRIVER', 'redis'),
It should be called directly$request->session()->set($sessionId, $data)
Can it be stored in Redis?
The subject should not update the session configuration in. env. Modify the following items in. env:
SESSION_DRIVER=redis