php - Session information not maintained while AJAX requests -


i creating session while rendering page. after calling ajax page every 4 seconds. ajax page doesnt gettign session information.

what may reason. whether ajax requests dont maintain session information?

code:

normal html

<body onload="timerint(11)"> <div style="display:none;">     <button id="prev"><<</button>     <button id="next">>></button> </div>  <div class="anyclass">     <ul id="news-ul">         <?php            include('render_latest.php');         ?>     </ul> </div> </body> 

render_latest.php

<?php session_start();  $con = mysql_connect("localhost","root","root"); mysql_select_db("test_db", $con); $i=1;  $lastresult=mysql_query("select max(epoch) latestepoch list_data");  while($row = mysql_fetch_array($lastresult))   {     //$_session['lastepoch'] =  $row['latestepoch'] ;     $_session['lastepoch']=12345;    }  $result=mysql_query("select * list_data order epoch desc limit 4 "); while($row = mysql_fetch_array($result))   {     echo '<li>';     echo $row['list_item'] . '<br/>' ;     echo $row['epoch'] . '<br/>';     echo $_session['lastepoch'];     echo '</li>';   }  ?>  

ajax page

<?php session_start();  $t=$_session['lastepoch']; $con = mysql_connect("localhost","root","root"); mysql_select_db("test_db", $con);  $result=mysql_query("select * list_data order epoch desc limit 1 ");  while($row = mysql_fetch_array($result))   {     echo '<li>';     echo $t;     echo $row['list_item'] ;     echo '</li>';   }  ?>  

the session data stored in cookies browsers, or can use query string of request pass parameters. eg: .../render_latest.php?lastepoch=123456 , read lastepoch parameter in php.

or can use html5 client-side storage in modern browsers.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -