SessionBehavior

Type
Class
Namespace
craft\behaviors
Inherits
craft\behaviors\SessionBehavior » yii\base\Behavior (opens new window) » yii\base\BaseObject (opens new window)
Implements
yii\base\Configurable (opens new window)
Since
3.0.0

Extends \yii\web\Session to add support for setting the session folder and creating it if it doesn’t exist.

View source (opens new window)

# Public Properties

Property Description
assetBundleFlashKey string (opens new window) – The name of the flash key that stores asset bundle data
assetBundleFlashes array (opens new window) – The queued-up asset bundles.
authAccessParam string (opens new window), null (opens new window) – The session variable name used to store the authorization keys for the current session.
error string (opens new window) – The message.
jsFlashKey string (opens new window) – The name of the flash key that stores JS data
jsFlashes array (opens new window) – The stored JS flashes.
notice string (opens new window) – The message.
owner (opens new window) yii\base\Component (opens new window), null (opens new window) – The owner of this behavior

# assetBundleFlashKey

Type
string (opens new window)
Default value
'__ab'

The name of the flash key that stores asset bundle data

View source (opens new window)

# assetBundleFlashes

Type
array (opens new window)
Default value
null
Access
Read-only

The queued-up asset bundles.

View source (opens new window)

# authAccessParam

Type
string (opens new window), null (opens new window)
Default value
null

The session variable name used to store the authorization keys for the current session.

See also:

View source (opens new window)

# error

Type
string (opens new window)
Default value
null
Access
Write-only

The message.

View source (opens new window)

# jsFlashKey

Type
string (opens new window)
Default value
'__js'

The name of the flash key that stores JS data

View source (opens new window)

# jsFlashes

Type
array (opens new window)
Default value
null
Access
Read-only

The stored JS flashes.

View source (opens new window)

# notice

Type
string (opens new window)
Default value
null
Access
Write-only

The message.

View source (opens new window)

# Public Methods

Method Description
__call() (opens new window) Calls the named method which is not a class method.
__construct() (opens new window) Constructor.
__get() (opens new window) Returns the value of an object property.
__isset() (opens new window) Checks if a property is set, i.e. defined and not null.
__set() (opens new window) Sets value of an object property.
__unset() (opens new window) Sets an object property to null.
addAssetBundleFlash() Queues up an asset bundle to be registered on a future request.
addJsFlash() Stores JS in the user’s flash data.
attach() (opens new window) Attaches the behavior object to the component.
authorize() Authorizes the user to perform an action for the duration of the session.
canGetProperty() (opens new window) Returns a value indicating whether a property can be read.
canSetProperty() (opens new window) Returns a value indicating whether a property can be set.
checkAuthorization() Returns whether the user is authorized to perform an action.
className() (opens new window) Returns the fully qualified name of this class.
deauthorize() Deauthorizes the user from performing an action.
detach() (opens new window) Detaches the behavior object from the component.
events() (opens new window) Declares event handlers for the owner (opens new window)'s events.
getAssetBundleFlashes() Returns the list of queued-up asset bundles in the session flash data.
getJsFlashes() Returns the stored JS flashes.
hasMethod() (opens new window) Returns a value indicating whether a method is defined.
hasProperty() (opens new window) Returns a value indicating whether a property is defined.
init() (opens new window) Initializes the object.
setError() Stores an error message in the user’s flash data.
setNotice() Stores a notice in the user’s flash data.

# addAssetBundleFlash()

Queues up an asset bundle to be registered on a future request.

Asset bundles that were queued with this method can be registered using getAssetBundleFlashes() or craft\web\View::getBodyHtml().

See also getAssetBundleFlashes() View source (opens new window)

Arguments

Throws

# addJsFlash()

Stores JS in the user’s flash data.

The JavaScript code will be stored on the session, and can be retrieved by calling getJsFlashes() or craft\web\View::getBodyHtml().

See also:

View source (opens new window)

Arguments

# authorize()

Authorizes the user to perform an action for the duration of the session.

View source (opens new window)

Arguments

# checkAuthorization()

Returns whether the user is authorized to perform an action.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

# deauthorize()

Deauthorizes the user from performing an action.

View source (opens new window)

Arguments

# getAssetBundleFlashes()

Returns the list of queued-up asset bundles in the session flash data.

See also addAssetBundleFlash() View source (opens new window)

Arguments

Returns

array (opens new window) – The queued-up asset bundles.

# getJsFlashes()

Returns the stored JS flashes.

See also addJsFlash() View source (opens new window)

Arguments

Returns

array (opens new window) – The stored JS flashes.

# setError()

Stores an error message in the user’s flash data.

The message will be stored on the session, and can be retrieved by calling \craft\behaviors\getFlash() or \craft\behaviors\getAllFlashes(). Only one flash error message can be stored at a time.

View source (opens new window)

Arguments

# setNotice()

Stores a notice in the user’s flash data.

The message will be stored on the session, and can be retrieved by calling \craft\behaviors\getFlash() or \craft\behaviors\getAllFlashes(). Only one flash notice can be stored at a time.

View source (opens new window)

Arguments