skip to Main Content

I use Redis to store sessions, but how do I get all of the user’s sessions? This is easy to do when using mysql, but how can I do it when using Redis?

2

Answers


  1. If you would like to retrieve all the data in the session, you may use the all method:

    $data = $request->session()->all();
    

    Check Laravel Docs

    Login or Signup to reply.
  2. To get all sessions you can do:

    $all_sessions = $request->session()->all();
    

    To get the sessions associated to the currently authenticated user:

    $user_sessions = DB::table('sessions')->where('user_id', Auth::user()->id)->get();
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search