setState is aimed at data that only applies to logged in users. If you want something to stick to a visitor then you really want Yii::app()->session[‘var’]. Yii::app()->session[‘var’] is a bit more low level (if you can call emulating state over a stateless protocol in an interpreted language low level) but it is just a wrapper for $_SESSION, there is only so much sugar you can add.
Sorry you’re right, I don’t know where I got that idea from. However logout does destroy the whole session by default and if you pass in false to CWebUser::logout() it will destroy states. So if you want data to persist across login/logout you would need to tell CWebUser::logout() not to destroy the session and store it in Yii::app()->session[‘variable’].