allowAutoLogin is set to true
Here is my current LoginForm:
public function authenticate($attribute, $params)
{
	if(!$this->hasErrors())  // we only want to authenticate when no input errors
	{
		$identity=new UserIdentity($this->username, $this->password);
		$identity->authenticate();
		switch($identity->errorCode)
		{
			case UserIdentity::ERROR_NONE:
				$duration=$this->rememberMe ? 3600*24*30 : 0; // 30 days
				Yii::app()->user->login($identity, $duration);
				break;
			case UserIdentity::ERROR_USERNAME_INVALID:
				$this->addError('username', 'Incorrect Login Details.');
				$this->addError('password', '');
				break;
			default: // UserIdentity::ERROR_PASSWORD_INVALID
				$this->addError('username', 'Incorrect Login Details.');
				$this->addError('password', '');
				break;
		}
	}
}
Here is my current UserIdentity:
public function authenticate()
{
    $record=User::model()->findByAttributes(array('email'=>$this->username, 'enabled'=>1));
    if($record===null)
        $this->errorCode=self::ERROR_USERNAME_INVALID;
    else if($record->password!==$this->password)
        $this->errorCode=self::ERROR_PASSWORD_INVALID;
    else
    {
        $this->_id=$record->id;
        $this->setState('name', $record->name);
	$this->setState('role', $record->type);
        $this->errorCode=self::ERROR_NONE;
    }
    return !$this->errorCode;
}
Here is my current accessRules():
public function accessRules()
{
	return array(
		array('allow', //allow authenticated users to view records
			'actions'=>array('view'),
			'users'=>array('@'),
		),
		array('allow', //allow only Admin users to create/update/delete records
			'actions'=>array('create', 'update', 'delete', 'list'),
			'expression'=>Yii::app()->user->getState('role')=='Admin',
		),
		array('allow', //allow authenticated users to view admin interface
			'actions'=>array('admin'),
			'users'=>array('@'), 
			),
		array('deny', //deny all users
			'users'=>array('*'),
		),
	);
}
In my user table I have a field called ‘type’ - this is set to either ‘Admin’ or ‘User’ - so I perform this check in the accessRules(). I think this is what may be causing the problem. Previously I was using [color="#000080"]‘expression’=>Yii::app()->user->role==‘Admin’[/color] but this started giving me errors after a certain period of inactivity ([color="#000080"]Property “CWebUser.role” is not defined[/color]). So I changed it to [color="#000080"]getState(‘role’)[/color].
In order to test I want to specify a very short duration - e.g. 2 mins and after that the login should expire and the user should get redirected to the login form.