Back to JoomlaStorage class

Method clear

public void
clear
()
Clears all variables from the session store
Returns
  • void
Since
  • 4.0.0
Class: JoomlaStorage
Project: Joomla

Method clear - Source code

/**
 * Clears all variables from the session store
 *
 * @return  void
 *
 * @since   4.0.0
 */
public function clear() : void
{
    $session_name = $this->getName();
    /*
     * In order to kill the session altogether, such as to log the user out, the session id
     * must also be unset. If a cookie is used to propagate the session id (default behavior),
     * then the session cookie must be deleted.
     */
    if (isset($_COOKIE[$session_name])) {
        $app = Factory::getApplication();
        $cookie_domain = $app->get('cookie_domain', '');
        $cookie_path = $app->get('cookie_path', '/');
        $cookie = session_get_cookie_params();
        setcookie($session_name, '', time() - 42000, $cookie_path, $cookie_domain, $cookie['secure'], true);
    }
    $this->data = new Registry();
}