How to delete a state in CWebUser ?

hi everyone,

i set a state in my application by using the :

Yii::app()->user->setState('foo','foo foo foo foo');

i want to destroy this state in a way that when i do a :


it must return me FALSE, that mean this state is completely destroyed.

In fact CWebUser has a method : clearStates() but i don’t want to clear other states.

is there a way to do it ?

@ karim gioca

read the doc : setState

public function setState($key,$value,$defaultValue=null)








it seems that if you set the same $key as null it will be destroyed:


i was looking into that last week, and i don’t think there is. I actually reverted to using session, much simpler and full control without needing to rely in user.


@ yiqing95 :

Yes it works, in fact when puting :


the value is removed from session and completely destroyed.

Thanx guys !!