[vox-tech] when is an html image "sent"?

Rod Roark rod at sunsetsystems.com
Sat Dec 17 09:59:01 PST 2005


OK I couldn't stand it and did a test.

test1.php:

  <?php
    session_start();

    if (!isset($_SESSION['count']))
       $_SESSION['count'] = 0;
    else
       $_SESSION['count']++;

    echo "Count is " . $_SESSION['count'] . "<br>";
    echo "<img src='test2.php'>";
  ?>

test2.php:

  <?php
    header("Content-type: image/png");

    session_start();

    if (!isset($_SESSION['count']))
       $_SESSION['count'] = 0;
    else
       $_SESSION['count']++;

    $im = @imagecreate(100, 50);
    $background_color = imagecolorallocate($im, 255, 255, 255);
    $text_color = imagecolorallocate($im, 233, 14, 91);
    imagestring($im, 1, 5, 5,  "Testing", $text_color);
    imagepng($im);
    imagedestroy($im);
  ?>

Everything seems to work, even with just cookies.  The count
increments by 2 on each refresh, and the image is displayed.

-- Rod


More information about the vox-tech mailing list