I think i found the reason. My index.php is in the frame of Yii, and it has a session with id, but the captcha.php is not within the framework, so they cannot share a session.I tried to make it a view(/validation/captcha ),but it won’t work that way, don’t know why.
Now the problem is how to use Yii session in captcha.php.
If it is important than looking at the source code above still could help you to create your own widget. (http://www.yiiframework.com/doc/api/1.1/CCaptchaAction - look at sessionKey). I am pretty sure you could easily change the logic of Yiis Captcha to show some calculations.
In fact changing CCaptchaAction’s generateVerifyCode() method should be enough.