How to prevent a session

When you go to the Facebook social network, I see that I can open 2 accounts (1 in Firefox, and the other in Internet Explorer) or several accounts. This is not so good, knowing that Facebook policy allows you to open a session at the same time.

When starting a session, how to prevent the same session from starting again (given the session name $_SESSION['user'] ) in another browser (Internet Explorer / Safari / Opera ...)?

Otherwise, how can I find out (with PHP) that a certain session is open in all browsers to prevent the session from opening twice?

+6
php session
source share
2 answers
 $token = hash('sha256', rand() . microtime() . $_SERVER['REMOTE_ADDR']) // rand as possible $_SERVER['user'] = $token; 
+2
source share

Instead of barring a new session from opening in a new browser if you already have an open session elsewhere, consider canceling any existing sessions for this user account when a new login appears. This minimizes user frustration and is easy to implement.

+1
source share

All Articles