What is the best way to combine CGI::Session  and CGI::Application

It was recommended that I use the cgiapp_init, which I am attempting to do.
But do I set the
$self->header_props inside the cgiapp_init sub then do nothing else. Or
should I follow the CGI::Session docs and initialize a new instance of
CGI.pm and print the header directly from the cgiapp_init sub?

Doing it as listed below does set the cookie and creates a session , but the
header is sent and mixed with the output from the rest of the module. Thus
giving me:

Content-Type: text/html; charset=ISO-8859-1

<html>
  <head><title>Test Template</title>
  <body>
  My Home Directory is
  <p>
  My Path is set to
/usr/local/sbin:/usr/sbin:/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
:/usr/local/sbin:/usr/bin/X11:/usr/X11R6/bin:/root/bin
  </body>
</html>


sub cgiapp_init {
        my $self = shift;
        # Optional Pre-Setup Initalization code

        use CGI;

        my $cgi = new CGI;

        my $c_sid = $cgi->cookie(COOKIE) || undef;

        my $session = new CGI::Session::File($c_sid,
                {
                        LockDirectory   => '/tmp/locks',
                        Directory       => '/tmp/sessions'
                });

        my $new_cookie = $cgi->cookie(-name=>COOKIE, -value=>$session->id);

        print $cgi->header(-cookie=>$new_cookie);

}


Any examples would be appreciated, and any links to online examples would
also be helpful. Searching deja for these two modules did not return any
posts I could learn from.


Thanks
zack

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/cgiapp@lists.vm.com/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to