can i not just create a cookie and then request its contents in the next line of the very same script?

Exactly.

The user agent (web browser) makes a request of the server. It has no cookie. It then waits for a response.

The web server receives the request and fills in all of the environmental variables. Since the user agent had no cookie when it made the request, $ENV{COOKIE} is not set. By the time your program gets control, CGI.pm attempts to pull a cookie out of $ENV{COOKIE}. The user agent still has no cookie. CGI.pm finds no cookie. Your program gets no cookie.

Your program then creates a cookie and sends information to the user agent.

The user agent will only send the cookie at its next request. You don't get an instantaneous reaction with this sort of programming. The client sends a chunk, then the server sends a chunk.

Make sense?


In reply to Re: The Cookie Monster Returns......$ENV on tripod??????? by chromatic
in thread The Cookie Monster Returns......$ENV on tripod??????? by Baz

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.