PDA

View Full Version : CGI::Session and Session ID


okwx
08-30-2007, 06:12 AM
Hi all,

I'm attempting to use CGI::Session to save state variables with a CGI.pm form script I have. In some initial test code I've written, whenever I drop the session ID as a cookie using the following code:

print $query->header( -cookie=>$cookie );

I see the following text displayed on the top of the form in my browser:

Expires: Wed, 29 Aug 2007 02:47:18 GMT Date: Thu, 30 Aug 2007 02:47:18 GMT Cache: no Content-Type: text/html; charset=ISO-8859-1

My question: Is there any way to supress the printing of this text to the browser window when the cookie is set? I know CGI.pm is returning http headers when setting the cookie, but I figure there has to be a way to keep this from showing up on my user's forms, unless I'm missing something or misunderstanding.

Thanks for any help.

FishMonger
08-30-2007, 08:53 AM
Are you printing the headers twice?

Use CGI::Session to send the header/cookies instead of the CGI module's header method.
use CGI::Session;

my $session = new CGI::Session();

# send proper HTTP header with cookies:
print $session->header();

okwx
08-30-2007, 04:28 PM
Yes, that was the problem, I was printing the header twice.

Thanks for the help!