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(














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


I am expecting both:



However, both keys will generate after first failed attempt.

Do you know why is this the case?

Thank you,


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');


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


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.


Where to put those codes ??[/size]