Php 限制登录次数

Php 限制登录次数,php,login,limit,Php,Login,Limit,我想根据设备的udid创建限制登录。例如,用户只能同时使用两个不同的设备登录。这就是我所做的,但在登录时无法锁定第三个用户 // Get the email and password $email = CParam::paramPost('email'); $firstpassword = CParam::paramPost('password'); $password = md5(CParam::paramPost('password')); $udid

我想根据设备的udid创建限制登录。例如,用户只能同时使用两个不同的设备登录。这就是我所做的,但在登录时无法锁定第三个用户

    // Get the email and password
$email       = CParam::paramPost('email');
$firstpassword    = CParam::paramPost('password');
$password    = md5(CParam::paramPost('password'));
$udid        = CParam::paramPost('udid');
$app_id      = CParam::paramPost('app_id');
$app_version = CParam::paramPost('app_version');

// Make sure we have a UDID
if (empty($udid)) {
    sendJsonError('UDID parameter is missing');
    return;
}

// Check if the user is entitled
$sql    = 'SELECT * FROM accounts WHERE email = :email AND password = :password';
$params = array('email' => $email, 'password' => $password);
$account   = $db->fetchOne($sql, $params);
if (!$account) {
    sendJsonError('We could not find your subscription.');
    return;
}

// The account was found, generate an successs token if not existing yet
if (empty($account['success_token'])) {
    $success_token = CGuid::create();
    $db->update(
        'accounts',
        array('success_token' => $success_token),
        'id = :id',
        array('id' => $account['id'])
    );
} else {
    $success_token = $account['success_token'];
}

// Register the device
$db->insertOrUpdate(
    'devices',
    array(
        'account_id'  => $account['id'],
        'udid'        => $udid,
        'app_id'      => $app_id,
        'app_version' => $app_version,
    )
);

谢谢

旁注:我希望您打算使用比MD5更安全的密码哈希,比如
password\u hash()。。或者条件在哪里?嗨@Jimmmy,不,我还没有创造条件。仍在试图找到如何在web上编写条件教程,但还没有人能够工作,请您提出建议。理论上,您必须存储一个唯一的登录标识(会话id就足够了),以及一个登录用户的标识(用户id),并将其保存在某个位置(db?)。因此,使用新登录,您可以检查该用户已注册(且在时间上有效)的会话数,并根据计数允许/拒绝该用户登录。。