implements Phalcon\Di\InjectionAwareInterface, Phalcon\Session\BagInterface, IteratorAggregate, Traversable, ArrayAccess, Countable
This component helps to separate session data into “namespaces”. Working by this way you can easily create groups of session variables into the application
$user = new \Phalcon\Session\Bag("user"); $user->name = "Kimbra Johnson"; $user->age = 22;
Phalcon\Session\Bag constructor
Sets the DependencyInjector container
Returns the DependencyInjector container
Initializes the session bag. This method must not be called directly, the class calls it when its internal data is accessed
Destroys the session bag
$user->destroy();
Sets a value in the session bag
$user->set("name", "Kimbra");
Magic setter to assign values to the session bag
$user->name = "Kimbra";
Obtains a value from the session bag optionally setting a default value
echo $user->get("name", "Kimbra");
Magic getter to obtain values from the session bag
echo $user->name;
Check whether a property is defined in the internal bag
var_dump( $user->has("name") );
Magic isset to check whether a property is defined in the bag
var_dump( isset($user["name"]) );
Removes a property from the internal bag
$user->remove("name");
Magic unset to remove items using the array syntax
unset($user["name"]);
Return length of bag
echo $user->count();
Returns the bag iterator
...
...
...
...
© 2011–2017 Phalcon Framework Team
Licensed under the Creative Commons Attribution License 3.0.
https://docs.phalconphp.com/en/latest/api/Phalcon_Session_Bag.html