Backend\Core\Engine\Authentication::logout PHP Method

logout() public static method

Logout the current user
public static logout ( )
    public static function logout()
    {
        // remove all rows owned by the current user
        BackendModel::get('database')->delete('users_sessions', 'session_id = ?', \SpoonSession::getSessionId());
        // reset values. We can't destroy the session because session-data can be used on the site.
        \SpoonSession::set('backend_logged_in', false);
        \SpoonSession::set('backend_secret_key', '');
        \SpoonSession::set('csrf_token', '');
    }

Usage Example

Example #1
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     BackendAuthentication::logout();
     // redirect to login-screen
     $this->redirect(BackendModel::createURLForAction('Index', $this->getModule()));
 }