PHP - session variable cannot be set
<p>I wrote a page 'captcha.php' to generate a math captcha and send the result through session to the page which request it.<br>
In captcha.php:</p>

<pre><code>$_SESSION['captcha'] = $var;//$var is the calculate result
</code></pre>

<p>In index.php:</p>

<pre><code>&lt;img src="/captcha.php"/&gt;&lt;input id="captchaa" type="text" name="a"/&gt;
...
&lt;?php    
if($_POST['a']==$_SESSION['captcha'])
...
</code></pre>

<p>But I got 'Undefined index: captcha' error.<br>
Any hint? Or what else more information do you need?</p>

<p>
UPDATE:
these lines are in both files

    if(!isset($_SESSION))
    {
        session_start();
    }
</p>

<p>
UPDATE:
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 generate image properly that way, don't know why.<br><br> Now the problem is how to use Yii's session in captcha.php.
</p>
