Restrict an account to be logged in only one place at a time

Source: Internet
Author: User

To limit the number of accounts can only be landed in one place, that is, the back of the landing will force the front landing of the person to exit, the front of the people to squeeze offline function

The idea is simply to save a currenthashmap<string,long> on the server side Logininfo

The key to this map is a string that uniquely identifies an account, such as ID, and so on, and value is the login time of the account.

An attribute is stored in the session of the logged in account, and the value of this property is the time of the login.

Then configure a filter in Web. XML, each request to determine the login time in the session of the account and the server memory in the account of the login time comparison, if the session in the logon time is less than the server in the memory of the login time, then the logon time is relatively early, forcing it to exit.

The specific code implementation is very simple, the idea is the most important

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.