Kill Duplicate Sessions On Server In Laravel 5.2
What is it about ?
The database session driver now includes user_id and ip_address so you can easily clear all sessions for a given user.
What's the Problem
Is there any blog that clearly explains on how to logout the duplicate sessions created using multiple IP address or through the same IP address using multiple browsers ?
As far as I see there is no difficulty with that.
Sample data in this table looks like below:
So you have here
user_id, browser and last activity timestamp. So if you want you can now add to cron for example running the following query:
select user_id, count(*) AS `total` FROM sessions GROUP by user_id HAVING count(*) > 1
This will give you users with multiple sessions and you'll be able to decide what to do with them. You can for example remove all sessions for those users or leave only the last one and remove all the others. It's up to you of course.
In the moment when you remove the record from database user will need to login again so for example above if I removed my session for Firefox, I need to login again in Firefox to be logged on my account.
Be aware that by default there is no
sessions table (because many users won't use
database driver for sessions). To create this table you need to run:
php artisan session:table
The above command will create sessions migration
and then you need to run
php artisan migrate
to apply this migration into database
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS - Conditionally Load a Different Page
- → Make a Laravel collection into angular array (octobercms)
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
- → Validating fileupload(image Dimensions) in Backend Octobercms
- → OctoberCMS Fileupload completely destroys my backend
- → How do I call the value from another backed page form and use it on a component in OctoberCms