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

  • Home
  • SEARCH
  • 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 808723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:36:33+00:00 2026-05-15T00:36:33+00:00

Is there anyway to detect when a user logins if there is already another

  • 0

Is there anyway to detect when a user logins if there is already another session with the same username, and block him from logging in again or send him a message?

  • 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-15T00:36:33+00:00Added an answer on May 15, 2026 at 12:36 am

    You could always implement the events in global.asax.

    Implement Application_Start() to setup a System.Collections.Dictionary (or at your preference) and store that in the Application[] collection, when a user logsin, add the username. Remove from the collection in Session_End(). Remember to use the ‘lock’ keyword while working with the collection 🙂

    Have fun!

    Example:

    [page.aspx]
    public partial class page : System.Web.UI.Page {
        protected bool Login(string userName) {
            System.Collections.Generic.List<string> d = Application["UsersLoggedIn"]
                as System.Collections.Generic.List<string>;
            if (d != null) {
                lock (d) {
                    if (d.Contains(userName)) {
                        // User is already logged in!!!
                        return false;
                    }
                    d.Add(userName);
                }
            }
            Session["UserLoggedIn"] = userName;
            return true;
        }
    
        protected void Logout() {
            Session.Abandon();
        }
    }
    
    [global.asax]
    <%@ Application Language="C#" %>
    <script RunAt="server">
        void Application_Start(object sender, EventArgs e) {
            Application["UsersLoggedIn"] = new System.Collections.Generic.List<string>();
        }
    
        void Session_End(object sender, EventArgs e) {
            // NOTE: you might want to call this from the .Logout() method - aswell -, to speed things up
            string userLoggedIn = Session["UserLoggedIn"] == null ? string.Empty ? (string)Session["UserLoggedIn"];
            if (userLoggedIn.Length > 0) {
                System.Collections.Generic.List<string> d = Application["UsersLoggedIn"] 
                    as System.Collections.Generic.List<string>;
                if (d != null) {
                    lock (d) {
                        d.Remove(userLoggedIn);
                    }
                }
            }
        }
    </script>   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there anyway, in PHP, to detect someone's username? I want to track the
Is there anyway to detect if a user clicks a link inside of an
Is there any way to detect session timeout without (user interaction)*, and redirect it
Is there anyway that we can detect when the system/screen gets locked and notify
Is there any way to detect if the iPhone wakes up from sleep while
Is there any way to detect SNI SSL support in rails? Judging from this
Is there any way to detect if a user has selected ok or cancel
Is it possible to detect touch events from within another application, specifically swipes? I'd
Is there anyway that I can find out if user has been holding Shift
Is there any way possible to detect if a user has disabled JavaScript after

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.