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

Peter Jay Salzman p at dirac.org
Sat Dec 17 07:16:07 PST 2005


On Sat 17 Dec 05, 12:15 AM, Rod Roark <rod at sunsetsystems.com> said:
> On Friday 16 December 2005 11:24 pm, Peter Jay Salzman wrote:
> > ... No matter what I try, though, I
> > can't access sessions from the captcha2.php file.  I guess it must interfere
> > with the image being sent to the client.
> 
> Oooh.  It must be that there's no mechanism for the browser to send
> the cookie (which contains the session ID) when it requests an
> image.  Sorry I caused you so much trouble.
> 
> I think what may work is to send the session ID in the URL.  That is,
> construct the image URL like this:
> 
>   $url = 'captcha2.php?' . session_name() . '=' . session_id();
> 
> and then your form requests the image with:
> 
>   <img src='<?php echo $url ?>'>
> 
> or whatever the equivalent is with Smarty.
> 
> I have not tried this, it's just my best guess from reading the docs.
 
Thanks Rod!

Unfortunately, it's still not working.  Here's what I tried:


Smarty template/web page "view_by_permalink.php":

   $smarty->assign('sessionId', session_id());
   $smarty->assign('sessionName', session_name());

   <img src="captcha2.php?{$sessionName}={$sessionId}" alt="validation string" />

captcha2.php:

   session_id( $_REQUEST['PHPSESSID'] );
   start_session();
   $_SESSION['captcha'] = $cmntPass;



Using error_log(), I determined that in captcha2.php, $_REQUEST['PHPSESSID']
is the correct session ID.  But something isn't right because if I stick

   error_log('hello world');

in captcha2.php before start_session(), the message appears in my error log.
But if I stick it in after start_session(), it doesn't appear.  So PHP seems
to be very unhappy with the start_session() line.

Needless to say, 'captcha' is an undefined $_SESSION index in the receiving
form.

I'm really on ground here.  I'm reading, but there's enough documentation to
drown in.

Have any idea on how to proceed?

Pete


More information about the vox-tech mailing list