Craft 3 Class Reference

Class craft\web\twig\variables\UserSession

Inheritance
craft\web\twig\variables\UserSession
Available since version
3.0
Deprecated since version
in 3.0
Source Code
https://github.com/craftcms/cms/blob/master/src/web/twig/variables/UserSession.php

User session functions.

Public Methods
Method Description Defined By
getFlash() Returns a flash message by a given key. craft\web\twig\variables\UserSession
getFlashes() Returns all flash data for the user. craft\web\twig\variables\UserSession
getRemainingSessionTime() Returns the number of seconds the user will be logged in for. craft\web\twig\variables\UserSession
getRememberedUsername() Returns the remembered username from cookie. craft\web\twig\variables\UserSession
getReturnUrl() Returns the URL the user was trying to access before getting sent to the login page. craft\web\twig\variables\UserSession
getUser() Returns the currently logged in user. craft\web\twig\variables\UserSession
hasFlash() Returns whether a flash message exists by a given key. craft\web\twig\variables\UserSession
isLoggedIn() Returns whether the user is logged in. craft\web\twig\variables\UserSession

Method Details

getFlash() public method #

Returns a flash message by a given key.

public mixed getFlash ( \craft\web\twig\variables\string $key, $defaultValue null, \craft\web\twig\variables\bool $delete true )
$key string
$defaultValue mixed
$delete boolean

getFlashes() public method #

Returns all flash data for the user.

public array getFlashes ( \craft\web\twig\variables\bool $delete true )
$delete boolean

getRemainingSessionTime() public method #

Returns the number of seconds the user will be logged in for.

public integer getRemainingSessionTime ( )

getRememberedUsername() public method #

Returns the remembered username from cookie.

public string getRememberedUsername ( )

getReturnUrl() public method #

Returns the URL the user was trying to access before getting sent to the login page.

public string getReturnUrl ( \craft\web\twig\variables\string $defaultUrl null )
$defaultUrl string, null The default URL that should be returned if no return URL was stored.
return string The return URL, or|null $defaultUrl.

getUser() public method #

Returns the currently logged in user.

public craft\elements\User, null getUser ( )

hasFlash() public method #

Returns whether a flash message exists by a given key.

public mixed hasFlash ( \craft\web\twig\variables\string $key )
$key string

isLoggedIn() public method #

Returns whether the user is logged in.

public boolean isLoggedIn ( )