Session deletion in Symfony 1.4

后端 未结 3 821
不知归路
不知归路 2021-02-10 06:04

How do I delete all session variables at once if they are not in Array?

PS I set them this way:

$this->getUser()->setAttribute(\'PayPalTransaction.         


        
3条回答
  •  灰色年华
    2021-02-10 06:39

    The sfUser class (which you get with $this->getUser()), keeps all it's attributes in a sfNamespacedParameterHolder. So the setAttribute() function on sfUser if merely a proxy to the sfNamespacedParameterHolder::setAttribute(). You can get the reference to this holder with sfUser::getAttributeHolder().

    The sfNamespacedParameterHolder also has a function clear(), which clears all attributes.

    So to clear all attributes, use: $this->getUser()->getAttributeHolder()->clear().

    (Please note that you will still be authenticated (e.g. logged in) when you clear the attribute holder).

提交回复
热议问题