Cevap Hem!
The main point:
You should never blindly accept cookies or sessions to validate users, both of which are easily stolen by XSS, and can be used by a malicious user other than the origin.
For user validation, since you're making a trip to validate the user anyway, there isn't really an overhead.
You are simply applying a value to when they logged in to the database, and validating it via some means on each page load.
A method I chose was a checkin-checkout method of the user's session state.
In which a unique ID is created on page load and a session variable stores this unique ID.
This unique ID is also stored for the User ID in the database, along with IP Address and IP changes. (I also stored other bits of info that are validated)
This can be used to prevent 2 separate browsers from being logged in at the same time for a single User ID, which can't be done with just sessions since sessions don't care who created them or when.
But with checkin-checkout, since the Unique ID is always different, a mismatch would occur.
The script validates the Unique ID from the session value and IP Address in the database. Once a match is made, change the Unique ID and update the database.
If the IP was changed within x seconds, do something for that user (Force new login), if the Unique ID's don't match do something else (such as logout, warn, etc), if last activity was x seconds ago do something for that user.
Yani Login-> Create Session / Kullanıcı Veritabanı Benzersiz Kimlik + Validate User-> Üret Yeni Oturum Benzersiz Kimlik-> Güncelleme Kullanıcı Son On / Benzersiz ID ile Doğrulama-> Sonraki Sayfa-> Validate Session
Sonunda size, kullanıcıların kendi hesaplarına erişim ve ne sıklıkta her noktadan nerede daha iyi bir bakış verebilir EG:. Çalışma x 3, x 5 ev, mobil x 1 Ve ayrıca hesabınızdan kullanıcıları korumak için izin verebilir hırsızlık. EG: Bir Alman kullanıcı aniden Tayland günlükleri, ya da ABD. Değişim onları bilgilendirmek ve e-posta değişikliğini doğrulamak için bir istek gönderin.