Session variable does not get updated within javascript code
<p>delete_define.php has the following code snippet:</p>

<pre><code>&lt;?php
    session_start();
?&gt;

&lt;form action="delete_now.php" target="upload_target"  onsubmit="return my_func_1();"&gt;
    &lt;input type="submit" name="my_submit" class="my_submit" value="submit"/&gt;
    &lt;iframe id="upload_target" name="upload_target" src1111="#" style="width:0;height:0;border:0px solid #fff;"&gt;&lt;/iframe&gt;
&lt;/form&gt;

&lt;script type="text/javascript"&gt;
    function my_func_1(){
       //alert("from within my_func() =" +&lt;?php echo $_SESSION['my_session'];  ?&gt;);
       alert(" my_func_1");
       return true;
    }

    function my_func_2(){
       alert("my_func_2 =" +&lt;?php echo $_SESSION['my_session'];  ?&gt;);
       return true;
    }
&lt;/script&gt;
</code></pre>

<p>delete_now.php has:</p>

<pre><code>&lt;?php
    session_start();
    $_SESSION['my_session']=rand();
?&gt;

&lt;script type="text/javascript"&gt;   
    alert("from within delete_now.php = " +&lt;?php echo $_SESSION['my_session'];  ?&gt;);
    window.top.window.my_func_2();
&lt;/script&gt;
</code></pre>

<p>The problem is my_func_2() does not give the same output for the session variable as the alert box in delete_now.php gives.</p>

<p>Why is that?</p>

<pre><code>EDIT: CHANGED THE CODE SAID TO BE IN delete_define.php
</code></pre>
