Cbaseuseridentity::setstate

The documentation says the following:

…the states stored via CBaseUserIdentity::setState will be saved in the cookie as well.

But if you use this method, variables are not stored in the $_COOKIE.

The CWebUser::setState method code is as follows:


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

{

	$key=$this->getStateKeyPrefix().$key;

	if($value===$defaultValue)

		unset($_SESSION[$key]);

	else

		$_SESSION[$key]=$value;

}



As you can see from the code, stored in the $_COOKIE is not there.

Can I do something wrong?

Well… you are looking at the code of CWebUser, not of CBaseUserIdentity.

It is the state of the identity that is persisted in a cookie.

I was not able to ensure that this method saves the data in the "COOKIE".

In the class "CBaseUserIdentity" as there is no code that would save the data in "COOKIE".

Saving to cookie is performed by saveToCookie method called from login(), so it only saves states set in the identity before using it to log user in.