OK, this time for the list. As I meant to do in the first place. One day 
maybe I'll remember that this list doesn't mung Reply-To headers.

Also in of list replies I pointed out that a simple way of handling 
changing from print()s to returning a string is to just:

my $returnstr = "";

$returnstr .= qq| ... |;

foreach $state (@states) {
        $returnstr .= qq| .... |;
}

$returnstr .= qq| .... |;
return $returnstr;

On Sun, 2004-10-17 at 08:05, Jonathan Mangin wrote:
> Hi all,
> 
> As is Dan Horne (C::A::P::S - new session every call) I'm upgrading some
> code, but I'm new to C::A. I haven't yet used HtmlTemplate or TT. At the
> moment I'd like to avoid it, if possible? In cgiapp_init I have this:
> 
> my $sid = $query->cookie('CGISESSID') || undef;
> my $session = new CGI::Session("driver:File", $sid, {Directory=>'/tmp'});
> $self->param('session'=>$session);
> if (!$sid or $sid ne $session->id) {
>    my $cookie = $query->cookie(-name => 'CGISESSID',
>                                -value => $session->id,
>                                -expires => '+1d');
>    $self->header_props(-cookie=>$cookie);
> #   print $query->header(-cookie=>$cookie);
> }
> 
> (Sorry 'bout that. Damn I hate cut & paste from unix to MS!)
> 
> After this, start_mode goes on to print a login HTML page on IE using print 
> qq`<html>...
> If a cookie isn't already set, Set-Cookie:... is printed (along with 
> Content-type:...)
> but the cookie doesn't get set unless I uncomment the above print statement.
> 
> I started to use ::Plugin::Session but backed off. I was using CGI::Simple 
> but the
> same happens with CGI.pm. What am I doing wrong? Is it because I'm using 
> print instead
> of templates?

Am I reading right that your run modes are directly print()ing you HTML
to standard out like a CGI script would?

Using CGI::Application your runmode sub should return the HTML as a
scalar, not print it. CGI::Application handles print()ing the result to
the HTTP connection. If I remember right it doesn't print the cookie
headers until after the runmode sub has been run which would explain why
your app works if you print the cookie header in cgiapp_init().


-- 
Tony Fraser
[EMAIL PROTECTED]
Sybaspace Internet Solutions                        System Administrator
phone: (250) 246-5368                                fax: (250) 246-5398


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[EMAIL PROTECTED]/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to