I have spent two days on this and cannot figure what is the problem with CGI!

I grab a username and password from one perl script and passit to another...It is in this next script that I generate a cookie. However, the cookie is not registered by the browser unless I issue the following lines:

print "Set-Cookie: $cookie1\n"; print "Content-Type: text/html\n\n";

However, I do not want to print the cookie to the screen! Please help, I have included the methods I have created and if you could let me know where Iam wrong please.

sub SetCookie { use CGI qw/:standard/; use CGI::Cookie; $cookie1 = new CGI::Cookie(-name=>'DB', -value=>{ username => $DBuser, password => $DBpasswd, }, -expires => '+1H'); print "Set-Cookie: $cookie1\n"; print "Content-Type: text/html\n\n"; } sub ReadCookie { %cookies = fetch CGI::Cookie; @id = $cookies{'DB'}->value; $exp = $cgi->header( -cookie => DB); print "$id[0] = $id[1]; $id[2] = $id[3]; Expiration = $exp"; }
Thanks, Siumon

In reply to CGI::Cookie issues by sdyates

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.