开发者

Duplicate User login

开发者 https://www.devze.com 2023-02-19 04:17 出处:网络
Is there an option to set Duplicate user login in PHP? W开发者_如何学Chen im logged in one tab and if i open another tab. It must display duplicate user or user already logged in. Kindly send me sugge

Is there an option to set Duplicate user login in PHP? W开发者_如何学Chen im logged in one tab and if i open another tab. It must display duplicate user or user already logged in. Kindly send me suggestions or the ways in which i can handle Duplicate user Login.


Well, store the user info in _SESSION vars

And at the top of page

<?php

check_login();

And on check_login() function

function check_login()
{
    session_start();

    if(isset($_SESSION['is_logged']))
    {
        echo "user is already logged";
    }
    else
    {
        echo "user is not logged";
    }
}

I am sure if you put this on top of every page, you will be able to do it so.

This will work for same browser. But for different browser, it will not work.


I'm afraid you can't do it since (as far as i see) e.g. Google's dupe login can't do the trick too. When you switch account within Google they actually switch the user but you can't login with two different identities in the same browser. Maybe somehow you can trick the browser but probably that will come with a security issue.

Btw, have you tried tricking cookies to do it?

Update:

  • build a database backend for manage (dupe) logins
  • use cookies beside sessions (store a unique value to differentiate each login)
  • on every page request compare your cookie > session > database to decide who requested the page

Note: this is a rough outline for the task, you'll need to take care of unique session_id's, etc.

0

精彩评论

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

关注公众号