Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7437281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:22:28+00:00 2026-05-29T10:22:28+00:00

I am developing an ASP.net site (using .NET 4, EF, jQuery Ajax, SQL Server

  • 0

I am developing an ASP.net site (using .NET 4, EF, jQuery Ajax, SQL Server 2008 R2). In this site I want to prevent multi-login. I mean if you log in to site, you can not log in to site again from other browser or computer since you are logged in already.

I plant an idea and developed it on my site, but it have a problem and it is because that problem that I decide to ask a question here

I have a SQL Server table like this :

Id        [int]            NOT NULL   IDENTITY(1,1)   //PK
UserId    [int]            NOT NULL                   //Relation to User table
Key       [nvarchar](50)   NOT NULL                   //Unique

When a user logs into the site, I insert a row into this table like this :

UserId = The Id of logged in user 
Key = Session.SessionId

and also there is a code for delete a record from this table that execute when:

  1. User try to log out from its account
  2. on Session_End event in global.asax

Everything works correct and perfect, just :

Problem: when the user closes the browser, that row does not get deleted (I thought when he close the browser, its row in that table will delete on Session_End event , but it did not!!!)

What can I do? Any solution for this problem? Should I change my strategy or there is a solution?

Sorry about my bad syntax. I am new in english

Any idea can be useful

regards

Foroughi

UPDATE1 : i do not use ASP membership and manage my users myself

UPDATE2 : i use InProc mode for my session state with 20 minutes timeout

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:22:29+00:00Added an answer on May 29, 2026 at 10:22 am

    The Session_End event doesn’t fire when the browser is closed, it fires when the server hasn’t gotten a request from the user in a specific time persion (by default 20 minutes). That means that if you use Session_End to remove users they wont be able to login for 20 minutes after they have closed the browser.

    Two alternative strategies come to mind

    1. You can use the onunload event in the browser to send a logout request to the server when the user leaves the page (This of course only works if the user still has net connectivity). The onunload event is also triggered when you reload the page, so you would have to keep track of why the event is triggered to use it.

    2. You keep the time of the last request in the user object. That way you can determine how active the user is, and how likely it is that they have left the site. For example find any user that has not done anything for two minutes and log them out.

    EDIT: As a final point raised in the comments. Instead of viewing your requirement as ‘you can only have one login so if your logged in already then don’t allow login‘ could you change to ‘you can only have one login if you have a session open it will be cancelled and a new one created.‘

    This way you still keep your one login session per account rule whilst providing a much more robust method of enforcing it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a site using ASP.NET, SQL 2008 and LINQ. I want to
I am using ASP.NET MVC for developing a web site. I am using jquery
Using ASP.NET MVC3 C# AND MS SQL 2008 I'm developing a Software As Service
I've been developing an asp.net web app using VS studio. I'm using SQL Server
I am currently developing an events calendar application using ASP.NET MVC and SQL Server
Do you think developing a ASP.Net site, with pure jQuery, AJAX and JSON web
I'm developing web site using asp.net. In my web site after login i set
I am tasked with developing a multi lingual site using ASP.NET MVC. For static
I am developing a site using asp.net and C# ( framework 1.1 ). Theres
I've been developing a site using ASP.NET MVC, and have decided to use the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.