How to prevent repeated login by a user name

Source: Internet
Author: User
How to prevent a user from logging on again means that a user logs on to another place. how can he determine whether a user has logged on again when logging on to another place with the same identity? It is best not to use a database !!, I suggest using the database. I just need to add a field. if there are two different logon locations, is the session unique? & Nbsp; in fact, how can multiple browsers prevent repeated login by one user name?
This means that a user has logged on to the same location. how can he determine whether he has logged on to another location when logging on to the same identity again? It is best not to use a database for implementation.

------ Solution --------------------
Top !!
------ Solution --------------------
Use the database to add a field.
------ Solution --------------------
If there are two different logon locations, is the session unique?
In fact, multiple browsers may generate multiple different sessions.

------ Solution --------------------
There must be a global variable in the login user name list. it seems that php does not have applications/static or other things, so it is better to have it in the database.
------ Solution --------------------
Don't worry about it. you can also use mmcache. The simplest way is to add a field that won't increase the load on your database. Because you need to determine this field as a condition during login, don't forget to add an index to this field.
------ Solution --------------------
Php does not have an application object, and the session object, that is, it does not seem to be able to traverse all sessions on the server in other dialogs. the general practice is to use the database, which actually does not occupy much resources, and the server provides a timer to regularly check whether the users in the server are still online. this is to prevent users from abnormally exiting.
------ Solution --------------------
If you want to restrict a user from logging on to a browser only in one place, the database is the best solution.
Sessions are automatically generated when a browser window is opened and automatically disappear when the window is closed. multiple sessions are generated even if the window is opened multiple times on the same computer, therefore, session does not solve the uniqueness of logon from different computers and opening multiple browser windows on the same computer;
The cookie value is saved on the local client. for the cookie value that has been saved on a computer, it is not automatically saved to another computer. Therefore, the cookie cannot solve the problem of unique login on different computers;

To sum up, we can only operate on databases to solve the problem of repeated login on different computers.

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.