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
  • 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. 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

A few years ago client Java was unsuitable for web development because a remarkable
A few years ago, I read a book that described how you could override
A few years ago we started playing around with XForms from the W3C for
A few years ago I have worked on a green field project where we
A few years ago I did a lot of work with CGI.pm. I'm evaluating
A few years ago, it was proven that PRIMES is in P . Are
I have a site a few years old that contains about 30 aspx Web
A few years ago, in the Windows environment, I did some testing, by letting
Over the past few years I've changed from having a long flowing page of
I've been using Subversion for a few years and after using SourceSafe , I

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.