Support the ongoing development of Laravel.io →
Laravel Authentication

Hi, I am creating an application with different set of users - clients, staff and admin. Each one will have it own set of interface so a staff cannot access admin interface and so on.

I have managed to tweak Laravel for multi-auth system (https://youtu.be/iKRLrJXNN4M) but the issues which I am facing are:

Sessions - Laravel still uses the default session assignment system for logged in users so when a user is accessing the client front end the user_id is captured from user table while for admin interface the user_id is captured from the admin table. While doing so the session id remains the same when accessing the user and admin interface from the "same" browser. I noticed this while testing the system. I need to tweak Laravel to create a separate session record when a user accesses the staff/admin panel and the user interface. Any hint on how I can do this? Currently I am using separate Guards for auth check so it verifies with the correct database table.

Ideally when the user successfully logs into the admin panel a fresh session record should be created a maintained separately. I think this will fix the issue of auto switching of "user_id" in the sessions table due to same session ID.

I think this has to do with the issue above. On the login form when I select "Remember Me" for client side, it works fine but on the same browser if I choose "Remember Me" for Admin form I get a Token Mismatch error. I think that is because the session IDs are the same. If this is not the issue, let me know how I can fix this.

Thanks.

Last updated 3 years ago.
0

Hi Hiren, I am not sure what roles are you trying to assign to what type of user. Making a single user sign in is a must behavior for most (i guess all applications). If you say so, i believe, it must be your requirement. Middlewares might be able to help you in access management. I am not exactly able to understand your problem. If you can portray a different example it would be good. One more thing, try to maintain a single user table and define roles within it... as the application size will grow it will be easier for you to manage. cheers!

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Hiren Mehta Hiren Mehta eludic Joined 3 Aug 2017

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.