E
E
epifanova19842016-01-30 09:53:13
PHP
epifanova1984, 2016-01-30 09:53:13

How to prevent two users from entering the site under the same login?

Hello everyone who took the time to read my post. Please help a beginner in PHP - programming. Faced such a problem: I can not write a script to enter the site. There are many ready-made scripts, made in different ways from primitive to using OOP with multi-role distribution of privileges. But they do not solve a seemingly simple problem: how to exclude the presence of two users on the site with the same login and password? I found only two scripts where this is written, the idea is simple, to enter the id of the current user session into the database, if a new one comes in with the same login and password, the session id is overwritten in the same database field and the previous friend is thrown out the next time he accesses the site. In practice, I did not succeed in throwing anyone away, which is strange - it seems that according to the code it should have flown out. But I don’t like the idea itself - I wouldn’t want to throw anyone away, you can simply not let anyone in, explaining to him that the reserved seat is already taken. Tell me how to do it? Unfortunately, general advice, such as: take the current session in the database, and then check if the cell in the database is occupied, they won’t help me, because is not yet strong enough in writing codes to implement them practically. I can already figure out how the finished code works, if not too fancy or detailed, what and how. Now I understand that you need to take a ready-made script and make some improvements, a few lines, but the skill is still not enough. Pros, take a couple of minutes, condescend to a beginner, show how it should be. Thanks in advance. type: take the current session in the database, and then check if the cell in the database is occupied, they won’t help me, because is not yet strong enough in writing codes to implement them practically. I can already figure out how the finished code works, if not too fancy or detailed, what and how. Now I understand that you need to take a ready-made script and make some improvements, a few lines, but the skill is still not enough. Pros, take a couple of minutes, condescend to a beginner, show how it should be. Thanks in advance. type: take the current session in the database, and then check if the cell in the database is occupied, they won’t help me, because is not yet strong enough in writing codes to implement them practically. I can already figure out how the finished code works, if not too fancy or detailed, what and how. Now I understand that you need to take a ready-made script and make some improvements, a few lines, but the skill is still not enough. Pros, take a couple of minutes, condescend to a beginner, show how it should be. Thanks in advance. that you need to take a ready-made script and make some improvements, a few lines, but the skill is still not enough. Pros, take a couple of minutes, condescend to a beginner, show how it should be. Thanks in advance. that you need to take a ready-made script and make some improvements, a few lines, but the skill is still not enough. Pros, take a couple of minutes, condescend to a beginner, show how it should be. Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor Alyakimov, 2016-01-30
@kaiten

Bad idea to not let in, you restrict the user. A person went to the site at work, but he won't go home anymore...
An adequate option is to throw the user out in old places and let them in new ones.

K
Karl Meinhoff, 2016-01-30
@KarleKremen

Create a new table in muscle for sessions. In it, store the session ID and the hash of the data you need, IP, for example. Rewrite when you log in. Every time you check the session on the site, refer to this table and check. If the data does not match - everything, departure

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question