|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-03-13 01:31 UTC] 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); ?> PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 18:00:01 2025 UTC |
I have tried the same code and followed what you told me. I have removed the session_destroy() and still, I am not able to extract any values from the session variables. I have noticed that it works when I used include("test2.php"). But I can't used this function since the real code that I have does generate real image. You should try the code and you will see what I mean. Thanks. I will wait for another response.