misc
(Haibhoang)
August 3, 2012, 5:31pm
1
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
gusarov
(Gusarov)
August 4, 2012, 8:16am
2
captcha for login? I don’t think so.Don’t waste your time.
misc
(Haibhoang)
August 6, 2012, 4:31pm
3
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.
outrage
(Site Sense Web)
August 7, 2012, 12:54pm
4
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.
misc
(Haibhoang)
August 7, 2012, 5:59pm
5
[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.
luizcelso
(Luiz Celso)
August 7, 2012, 6:21pm
6
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.
jayasam
(Jayasameera)
May 1, 2013, 3:32pm
7
misc:
[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.
[size="4"]
Where to put those codes ??[/size]