Login is not persistent

Hi I’m trying to login a user using the code below:

	$member = new MemberIdentity('user03','user03');


	if($member->authenticate()){


		Yii::app()->user->login($member);


	}


            echo 'userId = ' . Yii::app()->user->id;

I hardcoded the username and pw for testing. The user was able to login and userId = memberId. But when I refresh the page, with Yii::app()->user->login($member); uncommented, the userId becomes null and Yii::app()->user->isGuest = 1.

Am I missing something to make the log in persistent?

Here’s my config,

		'session'=>array(


			'autoStart'=>true,


			'timeout'=>1000000


		),


                    'user'=>array(


		        // enable cookie-based authentication


		        'allowAutoLogin'=>false,


	        ),

Why are you hard coding the user/pass when Yii ships with hardcoded values already (demo & admin remember?). The default installation has enough hardcoded values to test your login without touching the code. You should be able to login with demo/demo or admin/admin out of the box.

Thanks for the heads up!

I had a login problem and was looking around for days for an answer.

When I saw your code it gave me an idea and it WORKED!

Thanks for helping eventhough you didn’t intend to. =)