[NFR] Phalcon\Session\Bag::remove($index) method
It would be nice to have it, as it exists in Phalcon\Session\Adapter\Files class.
P.S. Also it would be nice to return boolean in this method - e.g. if index is not defined - method should return false.
smth like this (as example in extended class i'm currently using)
class Bag extends Phalcon\Session\Bag
{
public function remove($index)
{
if (isset($_SESSION[$this->_name][$index])) {
unset($_SESSION[$this->_name][$index]);
return true;
}
return false;
}
}
You can use $bag->destroy()
$bag->destroy() destroys whole bag, in some cases it's more usable to remove an index.
e.g. i have a service, that handles current user (session) and all it's states. when this service starts, it checks if $bag->has('somedata'). If bag does have, it performs some operations (db calls, etc), if doesn't - it does nothing.
If i will use $bag->set('somedata', null); - $bag->has('somedata') will return "true", so some extra db queries will be executed
Just as idea to think about, perhaps it is very rare case :)
+1
This was addressed in 1.0.0, thanks