index.php <?php $_SESSION['Set'] = mysql_query("Select * from SOMETABLE"); $_SESSION['Test']=“Testval“; redirect('Dummy.php'); ?> Dummy.php <?php echo $_SESSION['Test']; $myrow = mysql_fetch_array($_SESSION['Set']); echo $myrow['USERID']; ?> Why Dont I get the results from a Session's Dataset variable like any other Session's variables. How to pass datasets from page to page. Work on stake. Help needed. Thanks in advance.
Why on earth would you want to do that? Why not just pull up the necessary data on the respective pages?
Hello friend. Thanks for your reply. I did that through other way. Still, I want to know that it is possible to store a dataset as session variable. Just a curiosity. Thanks in Advance.
Yes it is possible. The best way would be to cast it to an array. $_SESSION['Set'] = mysql_query("Select * from SOMETABLE"); will not work, because mysql_query returns a resource and not a string or actual data. You would need to loop through the data, put it all into an array, serialize it, and store it as a session variable for it to work properly.
Is this what you're looking for? $result = mysql_query($_SESSION['Set']); while($row = mysql_fetch_array($result)) { $USERID[]=$row['USERID']; } $uid= implode(",", $USERID); echo $uid;
Yes it is possible, serialize the data. $_SESSION['data'] = serialize(mysql_query(" . . . ")); PHP: And on the page you want to access the data: $mysql_resource = unserialize($_SESSION['data']); PHP: