Trying to implement two account/user types using CWebUser. Need some help.

The website I am working on is in two parts. There is the backend admin area in which only approved users have access, and there is the frontend customer area.

Two keep these separate, I added the following code to create an account user for the front end. I retained the use of the ‘user’ for the backend admin area.


	

    'components'=>array(

        'user' => array(

		// enable cookie-based authentication

		'allowAutoLogin' => true,

	),

	'account' => array(

		'class' => 'CWebUser',

		// enable cookie-based authentication

		'allowAutoLogin' => true,

	), ...



However, I’m having some trouble logging in. I also added a new UserIdentity called AccountIdentity, an Account model, and a widget for logging in. The problem is that when I log in, the ‘account’ webuser does not appear to be updated and the ‘user’ is.

I’ve checked and checked the code, and nothing in my account login refers in anyway to user. So I’m at a loss as to why it is being updated.

I’m guessing that there is something that happens behind the scenes, possibly with session management, that writes to the user and not the second account webuser.

Does anyone have any idea how I can do this?

You need different stateKeyPrefix. Check this old topic: setStateKeyPrefix and auto-login in Modules

Thank you. That worked a treat.