UserSession
- Type
- Class
- Namespace
- craft\web\twig\variables
- Inherits
- craft\web\twig\variables\UserSession
- Since
- 3.0.0
- Deprecated in
- in 3.0.0
User session functions.
View source (opens new window)
# Public Methods
Method | Description |
---|---|
getFlash() | Returns a flash message by a given key. |
getFlashes() | Returns all flash data for the user. |
getRemainingSessionTime() | Returns the number of seconds the user will be logged in for. |
getRememberedUsername() | Returns the remembered username from cookie. |
getReturnUrl() | Returns the URL the user was trying to access before getting sent to the login page. |
getUser() | Returns the currently logged in user. |
hasFlash() | Returns whether a flash message exists by a given key. |
isLoggedIn() | Returns whether the user is logged in. |
# getFlash()
Returns a flash message by a given key.
View source (opens new window)
Arguments
$key
(string (opens new window))$defaultValue
(mixed
)$delete
(boolean (opens new window))
Returns
mixed
# getFlashes()
Returns all flash data for the user.
View source (opens new window)
Arguments
$delete
(boolean (opens new window))
Returns
# getRemainingSessionTime()
Returns the number of seconds the user will be logged in for.
View source (opens new window)
Returns
# getRememberedUsername()
Returns the remembered username from cookie.
View source (opens new window)
Returns
string (opens new window), null (opens new window)
# getReturnUrl()
Returns the URL the user was trying to access before getting sent to the login page.
View source (opens new window)
Arguments
$defaultUrl
(string (opens new window), null (opens new window)) – The default URL that should be returned if no return URL was stored.
Returns
string (opens new window) – The return URL, or|null $defaultUrl.
# getUser()
Returns the currently logged in user.
View source (opens new window)
Returns
craft\elements\User, null (opens new window)
# hasFlash()
Returns whether a flash message exists by a given key.
View source (opens new window)
Arguments
$key
(string (opens new window))
Returns
mixed
# isLoggedIn()
Returns whether the user is logged in.
View source (opens new window)