Hi,
We're using Redis as our session store in a Laravel 7 project.
In the user's account dashboard, we want to provide UI for managing their current sessions. (example)
I found this solution, but it requires the database session driver.
There's also hamedmehryar/laravel-session-tracker, but it hasn't been updated in a few years and fails to install on a fresh L7 project. I'm not sure it would work with L7 and/or Redis as the session driver, or if it's even an ideal solution in general.
At this point, it seems we may have to roll our own session tracking middleware/model/migration/etc., recording and tracking sessions in a SQL table. Roughly speaking:
- Listen for
Illuminate\Auth\Events\Login and Illuminate\Auth\Events\Logout events, then update our SQL db table with the session id (along with metadata such as device name, etc.).
- If the user clicks to "Log out" one or all of the sessions, we can do
Session::forget() on each session id and also delete those records from the SQL table
Was wondering if anyone else has encountered a session management requirement when using Redis as a session store, and how you handled it.
Thank you!