About LaravelSession User-Defined Driver

Source: Internet
Author: User
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 sessionStorage.
However, after configuration laravelOr sessionStored 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.phpAdded the self-writtenApp\Providers\SessionServiceProvider::class,Go in.
And replacedapp\config\session.phpInside'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 sessionStorage.
However, after configurationlaravelOrsessionStored 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.phpAdded the self-writtenApp\Providers\SessionServiceProvider::class,Go in.
And replacedapp\config\session.phpInside'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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.