Session Trait

trait Atk4\Ui\SessionTrait


SessionTrait is a simple way to let object store relevant data in the session. Specifically used in ATK UI some objects want to memorize data. (see

You would need 3 things. First make use of session trait:

use \Atk4\Ui\SessionTrait;

next you may memorize any value, which will be stored independently from any other object (even of a same class):

$this->memorize('dsn', $dsn);

Later when you need the value, you can simply recall it:

$dsn = $this->recall('dsn');


property Atk4\Ui\SessionTrait::$rootNamespace

Internal property to make sure that all session data will be stored in one “container” (array key).



Create new session.


Close existing session.

Atk4\Ui\SessionTrait::memorize($key, $value)

Remember data in object-relevant session data.

Atk4\Ui\SessionTrait::learn($key, $default = null)

Similar to memorize, but if value for key exist, will return it.

Atk4\Ui\SessionTrait::recall($key, $default = null)

Returns session data for this object. If not previously set, then $default is returned.

Atk4\Ui\SessionTrait::forget($key = null)

Forget session data for arg $key. If $key is omitted will forget all associated session data.