Howdy!

I have done cookies with Perl before which are accomplished like so:
$susername = cookie(-name => 'username', -value => $userinput, -expires => '+10m', );

Then before the page starts pass the follow in the header:
print header(-cookie => [$susername]);

I used [] around $susername because I usually have more than one scalar being pushed into a cookie.
The Question:
Can a cookie be created without headers? I have a script that takes in a form, and submits into itself. Does some validation on the perl-side (it also has Javascript validation, but that is irrelevant. Then if the validation is a success the script will past them a cookie and redirect them to another page (page two of the form). Is this possible? Can I "pass the user a cookie" without declaring the cookie in the headers. What are my other options besides having to print a "bogus page" with a redirect message and having a cookie created at that point?

I have been thinking about this all weekend, but that last case scenario is the only possible outcome I can think of, and I don't like it. Monks, please help me!

In reply to CGI Cookies by Trihedralguy

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.