Contao\User::logout PHP Метод

logout() публичный Метод

Remove the authentication cookie and destroy the current session
public logout ( ) : boolean
Результат boolean True if the user could be logged out
    public function logout()
    {
        // Return if the user has been logged out already
        if (!\Input::cookie($this->strCookie)) {
            return false;
        }
        $intUserid = null;
        // Find the session
        $objSession = $this->Database->prepare("SELECT * FROM tl_session WHERE hash=?")->limit(1)->execute($this->strHash);
        if ($objSession->numRows) {
            $this->strIp = $objSession->ip;
            $this->strHash = $objSession->hash;
            $intUserid = $objSession->pid;
        }
        $time = time();
        // Remove the session from the database
        $this->Database->prepare("DELETE FROM tl_session WHERE hash=?")->execute($this->strHash);
        // Remove cookie and hash
        $this->setCookie($this->strCookie, $this->strHash, $time - 86400, null, null, \Environment::get('ssl'), true);
        $this->strHash = '';
        \System::getContainer()->get('session')->invalidate();
        \System::getContainer()->get('security.token_storage')->setToken(null);
        // Add a log entry
        if ($this->findBy('id', $intUserid) != false) {
            $GLOBALS['TL_USERNAME'] = $this->username;
            $this->log('User "' . $this->username . '" has logged out', __METHOD__, TL_ACCESS);
        }
        // HOOK: post logout callback
        if (isset($GLOBALS['TL_HOOKS']['postLogout']) && is_array($GLOBALS['TL_HOOKS']['postLogout'])) {
            foreach ($GLOBALS['TL_HOOKS']['postLogout'] as $callback) {
                $this->import($callback[0], 'objLogout', true);
                $this->objLogout->{$callback[1]}($this);
            }
        }
        return true;
    }