Hello,
I have an mvc web application. Now i have a requirement to not allow the same/different user to login from same browser when a user is already logged in.
Please help to find a solution for this.
Hello,
I have an mvc web application. Now i have a requirement to not allow the same/different user to login from same browser when a user is already logged in.
Please help to find a solution for this.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Tahir AnsariRank #366 · 6.8K reputationPosted Sep 2, 2024, 12:43 PM EDT
You can store active session
CREATE TABLE ActiveSessions ( SessionId NVARCHAR(255) PRIMARY KEY, UserId INT, BrowserInfo NVARCHAR(255) );On User Login
Check Existing Sessions:
Query the ActiveSessions table to see if there’s an active session for the user with the same BrowserInfo.
Invalidate Old Session:
If an existing session is found, remove it.
Create New Session:
Insert a new record with the SessionId, UserId, and BrowserInfo