开发者

How to prevent a session

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

When star开发者_JS百科ting a session, how to prevent the same session (considering the session name $_SESSION['user']) from being re-opened in another browser (Internet Explorer/Safari/Opera...)?

Otherwise, how can I know (with PHP) that a certain session is open in all browsers to prevent the session to be open twice?


$token = hash('sha256', rand() . microtime() . $_SERVER['REMOTE_ADDR']) // rand as possible
$_SERVER['user'] = $token;


Instead of preventing a new session from being opened in a new browser if there is already an open session elsewhere, consider invalidating any existing sessions to that user account when a new Sign In occurs. This will minimise user frustration, and is simple to implement.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜