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 51949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:49:50+00:00 2026-05-10T16:49:50+00:00

A few years ago I developed a web app for which we wanted to

  • 0

A few years ago I developed a web app for which we wanted to make sure the users weren’t sharing credentials.

One of the things we decided to to, was only allow the user to be logged in from one computer at a time. The way I did this, was to have a little iframe ping the server every N seconds; as long as the server had a heartbeat for a particular user (from a particular IP), that user was not allowed to log in from any other IP.

The solution, although approved by my manger, always seemed hacky to me. Also, it seems like it would be easy to circumvent.

Is there a good way to make sure a web app user only logs in once? To be honest, I never understood why management even wanted this feature. Does it make sense to enforce this on distributed apps?

  • 1 1 Answer
  • 4 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. 2026-05-10T16:49:50+00:00Added an answer on May 10, 2026 at 4:49 pm

    I’ve implemented this by maintaining a hashtable of currently logged in users, the key was the username, the value was their last activity time.

    When logging in, you just check this hashtable for the key, and if it exists, reject the login.

    When the user does anything, you update the hashtable with the time (This is easy if you make it part of the core page framework).

    If the time in the hashtable is greater than 20 minutes of inactivity, you remove them. You can do this every time the hashtable is checked, so even if you only had one user, and the tried to login several hours later, during that initial check, it would remove them from the hashtable for being idle.

    Some examples in C# (Untested):

    public Dictionary<String,DateTime> UserDictionary {     get     {         if (HttpContext.Current.Cache['UserDictionary'] != null)         {             return HttpContext.Current.Cache['UserDictionary'] as Dictionary<String,DateTime>;         }         return new Dictionary<String,DateTime>();     }     set     {         HttpContext.Current.Cache['UserDictionary'] = value;     } }  public bool IsUserAlreadyLoggedIn(string userName) {     removeIdleUsers();     return UserDictionary.ContainsKey(userName); }  public void UpdateUser(string userName) {     UserDictionary[userName] = DateTime.Now;      removeIdleUsers(); }  private void removeIdleUsers() {    for (int i = 0; i < UserDictionary.Length; i++)         {             if (user[i].Value < DateTime.Now.AddMinutes(-20))                 user.RemoveAt(i);         } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Few years ago I've developed a windows service app (VB.NET framework 1.1) which was
A few years ago I looked into using some build system that isnt Make
Few years ago (2005), a colleague created a VS2005 project an Web Application and
A few years ago in Oracle 10 or 9 I used a function which
I few years ago I created a database driven ASP.NET site, which uses a
So a few years ago I saw the DB schema of a system developed
A few years ago I wrote a WCF service, which runs on a Windows
A few years ago Eric Lippert blogged about a hypothetical infoof operator that would
A few years ago I helped someone put together a webpage (for local personal
A few years ago I came across a T-SQL technique to validate a stored

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.