Multi User Multi Login | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Multi User Multi Login

I have two different users in my database (admin & normal user) in two different tables and also two login page. If I login as user, user's home page will be opened, and in case of admin, admin panel will be opened. I am using the same name for session variables e.g. $_SESSION['isLoggedIn']. It is set to true during login. So my question is if I login as a user, I will be able to access admin panel as it checks whether the isLoggedIn is true or not at the top of the page. I don't have much idea how to implement multiple user without using same table for all users. I can use different name for the session variables like isLoggedInUser and isLoggedInAdmin, but don't want to do that. So what is the best way to implement the feature so that one user can't access other user's data.

11th Dec 2022, 10:01 AM
Kashyap Kumar
Kashyap Kumar - avatar
3 Answers
+ 2
Do you have any other checks that differentiate a user from an admin? Maybe that's what you could put in before the isLoggedIn... then only allow each person access to their correct site.
12th Dec 2022, 10:45 AM
Ausgrindtube
Ausgrindtube - avatar
+ 2
I have used another session variable isAdmin to identify the admin. It solved my problem.
12th Dec 2022, 5:42 PM
Kashyap Kumar
Kashyap Kumar - avatar
+ 1
Good thinking! Happy coding
13th Dec 2022, 7:37 AM
Ausgrindtube
Ausgrindtube - avatar