Good evening ( currently
) to all gurus of this site. Such a thing (I did not notice and did not come across before). I tested the site and opened it in another tab. In the case! A split personality occurred at the session variables ( $_SESSION['login']
). How to prevent duplicate entry to the site? In my head there is an option - to create a field "status" in the table and write there "online" / "not online". I do not know if it is right or not. This also applies to logging in from another browser with the same, say, login. Although this creates a new session, but still ...
|
1 answer
Hello.
I solved this problem in the following way:
- Created a row in the table of users
online
1-Online | 0-Offline
During authorization I checked if online==1
Then we skip the script, and if not, then no.
But at the same time, I checked the last activity of the user, if she changed online
to 0 more than 5 minutes .
That's all :)
- @IamS, 1) 5 minutes IMHO is not enough, I guess. 2) If you go to the site twice from the same browser, then authorization will not be requested, then one session is active. It is necessary to check whether the check for online will work in this case - Deus
- @Deus; You can add to the script:
<?php session_start(); if(isset($_SESSION['login'])){ echo "Π£ΠΆΠ΅ ΠΏΡΠΎΡ ΠΎΠ΄ΠΈΠ»ΠΈ Π°Π²ΡΠΎΡΠΈΠ·Π°ΡΠΈΡ"; } else{ //ΠΠ²ΡΠΎΡΠΈΠ·Π°ΡΠΈΡ } ?>
<?php session_start(); if(isset($_SESSION['login'])){ echo "Π£ΠΆΠ΅ ΠΏΡΠΎΡ ΠΎΠ΄ΠΈΠ»ΠΈ Π°Π²ΡΠΎΡΠΈΠ·Π°ΡΠΈΡ"; } else{ //ΠΠ²ΡΠΎΡΠΈΠ·Π°ΡΠΈΡ } ?>
<?php session_start(); if(isset($_SESSION['login'])){ echo "Π£ΠΆΠ΅ ΠΏΡΠΎΡ ΠΎΠ΄ΠΈΠ»ΠΈ Π°Π²ΡΠΎΡΠΈΠ·Π°ΡΠΈΡ"; } else{ //ΠΠ²ΡΠΎΡΠΈΠ·Π°ΡΠΈΡ } ?>
- k0mar
|