public function startSession($user_id)
    {
        $this->deleteOldSessions();

        $user_id = (int)$user_id;
        $sid = $this->generateUserSid($user_id);

        $session = UsersSessionEntityRepository::findOneEntityByCriteria([
            'sid'     => $sid,
            'user_id' => $user_id,
        ]);
        if (!$session) {
            $session = new UsersSessionEntity();
        }
        $session->setSid($sid);
        $session->setUserId($user_id);
        $session->save();

        return $sid;
    }