ID: 22671 Updated by: [EMAIL PROTECTED] Reported By: ronneil at restricted dot dyndns dot org -Status: Open +Status: Analyzed Bug Type: Session related Operating System: FreeBSD 4.7 and Redhat 7.3 PHP Version: 4.3.0 New Comment:
You explicitly destroy the session right there at the bottom of test1.php. Why do you think that the session will still be around by the time the request for the test2 image comes through? Chances are that test1 has finished executing by then and thus you session data has been destroyed. Previous Comments: ------------------------------------------------------------------------ [2003-03-13 01:31:31] ronneil at restricted dot dyndns dot org I am trying to retrieve values from a SESSION variable array. To retrieve, I am using <img src=somefile.php>. Unfortunately, I am not able to see any value. Below are 2 sample php files to recreate the error. "test1.php" calls "test2.php" via <img src> TAG. Currently in production, I have a working code (http://restricted.dyndns.org/codes/ocishow1.php) that uses almost same concept below but this one saves the data to a file first. This code calls another php file (http://restricted.dyndns.org/codes/ocishow2.php) to generate the graph and is called via <img src>. --------------TEST CODE------------------- FILENAME : test1.php <?php session_start(); $time_VAR = array(2343,3234,457,2356,6798,3467,34667,4578,2523); for ($ipage=0;$ipage<4;$ipage++) { for ($i=0;$i<count($time_VAR);$i++) { $_SESSION[$ipage][] = $time_VAR[$i]; } // the following loop verifies if SESSION variable was populated for ($i=0;$i<count($_SESSION[$ipage]);$i++) { echo "$i.) ".$_SESSION[$ipage][$i]."<br>"; } $pagenum = $ipage; $arraysize = count($_SESSION[$ipage]); echo "Pagenum : $pagenum, Size of current array : $arraysize<br>"; echo '<img src="test2.php?count='.$pagenum.'&varsize='.$arraysize.'">'; echo "New line<br><br>"; } session_destroy(); ?> ------------------------------------------------- FILENAME : test2.php <?php session_start(); $index = $_GET[count]; $arraysize = $_GET[varsize]; // file handling was written to verify the size of array and index if there are really values on it $fp1 = fopen("/tmp/checkval.txt","w"); $err = fwrite($fp1,"Pagenum : $index, Size of Array: $arraysize\n"); fclose($fp1); for ($i=0;$i<$arraysize;$i++) { $atemp_alltel_VAR[] = $_SESSION[$index][$i]; } // This is the only way I can verify $fp = fopen("/tmp/testing","w"); for ($i=0;$i<count($atemp_alltel_VAR);$i++) { $err = fwrite($fp, $atemp_alltel_VAR[$i]); } fclose($fp); ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=22671&edit=1
