Two captchas on one page

I have two captchas on one page. One for the Member login and another for Guest login form.




public function actions()

{

    return array(

	'captcha1'=>array(

		'class'=>'CCaptchaAction',

		'backColor'=>0xFFFFFF,

	),


	'captcha2'=>array(

		'class'=>'CCaptchaAction',

		'backColor'=>0xFFFFFF,

	),




	'page'=>array(

		'class'=>'CViewAction',

	),

    );

}




However, only one of the key is generated in the yii session table:

Yii.CCaptchaAction.3bbe352e.controllername.captcha|s:7:"xemobin"

I am expecting both:

Yii.CCaptchaAction.3bbe352e.controllername.captcha|s:7:"xemobin"

Yii.CCaptchaAction.3bbe352e.controllername.captcha2|s:8:"derbdgha"

However, both keys will generate after first failed attempt.

Do you know why is this the case?

Thank you,

MISC

captcha for login? I don’t think so.Don’t waste your time.

We don’t have a choice but we have to have the catchas. It’s a biz requirement.

What is odd is that the captcha are randomly added to the session database. It’s not predictable at all.

I never saw 2 captchas on 1 page anywhere before but the simple answer would be to render the same captcha for both forms in your view.

[SOLVED] I reviewed the getVerifyCode method in the CCaptchaAction class and I saw they have a line where if the sessionkey for the first captcha in the db then it doesn’t create again. I forced it to create by calling the following lines before render the widget:


$captcha = Yii::app()->getController()->createAction('captcha');

$captcha->getVerifyCode(true);




$captcha2 = Yii::app()->getController()->createAction('captcha2');

$captcha2->getVerifyCode(true);

the parameter true in this method getVerifyCode(true) is the key.

Ins’t my business, but two captchas in one page is craziness. So, why don’t use the some for both forms.

Bu the solution would be usefulness.

Happy coding.

[size="4"]

Where to put those codes ??[/size]