One system allows up to 10 people in the same account to log in online at the same time, how to do it

Source: Internet
Author: User
A system allows up to 10 people in the same account to log on online at the same time, how to do it?
A system allows up to 10 people in the same account to log on online at the same time, how to do it? Let's talk about our ideas.

------Solution--------------------
Is it an internal system?

Build a table Logs table
IP user_id last_time

Assuming that it's online in 10 minutes
WHERE last_time+600 > Time () plus GROUP by user_id is more than 10, you are not allowed to log in.
last_time+600 < time () is deleted.

We have to practice testing ...
------Solution--------------------
Landing is landing, the limit is limited.

A login to a session, and ordinary users no difference.

The limit is extra, each account has a database Count field, and the question is how to expire a certain user login.
The user logs off every time, then the operation of the database-1 is good. If the user does not log off, then the database should be counted at the same time as the session expires-1, so that the user is more reasonable. But it's hard to make the session's expiration date and count-1 automatic association run, that is, a login session expired, and the database has not-1, which is not fair to the user.

So, if you can register a session expiration callback to manipulate the database count-1 is good, but do not know that there is no php.ini can be configured to invoke a callback PHP file? Not expected.

So, I finally give the solution is: the user does not log off forever keep its landing state, relying on a separate cookie maintenance ... Run a php timed script by crontab, to those who keep more than n long in the login status delete their database cookie record and give technology-1, so that the other users, and the original landing of the classmate also have no words to say, can only re-attempt to land.

Add a table: auto_id user cookie, each user's landing point corresponding to a cookie, limit the table with a user cookie no more than 10 limit 10 people to login, as long as the cookie generated to each landing, as long as they do not log off, They remain online for some time, and PHP detects who they are or whether they are using cookies in the database. In order to clean up those users who did not log off, only run crontab timed cleanup.




Summarize! ~~~~~ in fact, because the session always expires, expired can not be traced, so it is necessary to persist the session to the database!!!
Second, because the session expires unable to callback function, so only persistent after the regular run crontab cleanup timeout cookie~~~~


------Solution--------------------
discuss

Landing is landing, the limit is limited.

A login to a session, and ordinary users no difference.

The limit is extra, each account has a database Count field, and the question is how to expire a certain user login.
The user logs off every time, then the operation of the database-1 is good. If the user does not log off, then the database should be counted at the same time as the session expires-1, so that the user is more reasonable. However, it is difficult to make the session's expiration date and count-1 automatic association run, namely a certain login ...

------Solution--------------------
Customize your session handler, the advantage is no need to change the code elsewhere
http://ca3.php.net/manual/en/class.sessionhandler.php


Of course, some of the upstairs methods can do the same.

Look at your own specific needs and existing implementations






------Solution--------------------
Explore

Reference:

Landing is landing, the limit is limited.

A login to a session, and ordinary users no difference.

The limit is extra, each account has a database Count field, and the question is how to expire a certain user login.
The user logs off every time, then the operation of the database-1 is good. If the user does not log off, then the database should be counted at the same time as the session expires-1, so that the user is more reasonable. But it's hard to get the session to expire and Count-......

------Solution--------------------
discuss

Customize your session handler, the advantage is no need to change the code elsewhere
http://ca3.php.net/manual/en/class.sessionhandler.php


Of course, some of the upstairs methods can do the same.

Look at your own specific needs and existing implementations

------Solution--------------------
discuss
If the landlord asked is a system only allow the same account to be logged in once
Is that how you answer?

------Solution--------------------
Explore

Reference:

Customize your session handler, the advantage is no need to change the code elsewhere
http://ca3.php.net/manual/en/class.sessionhandler.php


Of course, some of the upstairs methods can do the same.

Look at your own specific needs and existing implementations


See this session handler, do not know the expiration will not callback destroy Callba ...
  • 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.