i am creating session while rendering the page. After that i am calling the AJAX page every 4 seconds. the AJAX page doesnt gettign the Session information.
What may be the 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) as latestepoch FROM list_data");
while($row = mysql_fetch_array($lastresult))
{
//$_session['lastepoch'] = $row['latestepoch'] ;
$_session['lastepoch']=12345;
}
$result=mysql_query("SELECT * FROM list_data order by 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 * FROM list_data order by epoch desc LIMIT 1 ");
while($row = mysql_fetch_array($result))
{
echo '<li>';
echo $t;
echo $row['list_item'] ;
echo '</li>';
}
?>