Class **Phalcon\\Session\\Bag** =============================== *implements* :doc:`Phalcon\\Di\\InjectionAwareInterface `, :doc:`Phalcon\\Session\\BagInterface `, IteratorAggregate, Traversable, ArrayAccess, Countable .. role:: raw-html(raw) :format: html :raw-html:`Source on GitHub` This component helps to separate session data into "namespaces". Working by this way you can easily create groups of session variables into the application .. code-block:: php name = "Kimbra Johnson"; $user->age = 22; Methods ------- public **__construct** (*unknown* $name) Phalcon\\Session\\Bag constructor public **setDI** (:doc:`Phalcon\\DiInterface ` $dependencyInjector) Sets the DependencyInjector container public **getDI** () Returns the DependencyInjector container public **initialize** () Initializes the session bag. This method must not be called directly, the class calls it when its internal data is accesed public **destroy** () Destroyes the session bag .. code-block:: php destroy(); public **set** (*unknown* $property, *unknown* $value) Sets a value in the session bag .. code-block:: php set('name', 'Kimbra'); public **__set** (*unknown* $property, *unknown* $value) Magic setter to assign values to the session bag .. code-block:: php name = "Kimbra"; public **get** (*unknown* $property, [*unknown* $defaultValue]) Obtains a value from the session bag optionally setting a default value .. code-block:: php get('name', 'Kimbra'); public **__get** (*unknown* $property) Magic getter to obtain values from the session bag .. code-block:: php name; public **has** (*unknown* $property) Check whether a property is defined in the internal bag .. code-block:: php has('name')); public **__isset** (*unknown* $property) Magic isset to check whether a property is defined in the bag .. code-block:: php remove('name'); public **__unset** (*unknown* $property) Magic unset to remove items using the array syntax .. code-block:: php count(); final public *\ArrayIterator* **getIterator** ()  Returns the bag iterator final public **offsetSet** (*string* $property, *mixed* $value) final public **offsetExists** (*string* $property) final public **offsetUnset** (*string* $property) final public **offsetGet** (*string* $property)