Samn has asked for the wisdom of the Perl Monks concerning the following question:

Replies are listed 'Best First'.
Re: General cookie information
by swiftone (Curate) on Apr 16, 2002 at 20:58 UTC
    An easy way to determine what is happening behind the scenes with HTML is to look at it without any HTTP interpretation. For example, running your example on the command line give me:
    Set-Cookie: USER_ID=1; domain=.robotskull.com; path=/; expires=Thu, 16 +-May-2002 20:48:56 GMT Date: Tue, 16 Apr 2002 20:48:56 GMT Content-Type: text/html; charset=ISO-8859-1
    (If you're on Windows or some other non *nix system and the command line is a new concept for you, I suggest you get used to using it on occasion. For some tasks it simply can't be beat.)

    Update: It's a subtle bug that often catches new cookie programmers (I know it caught me) -- Don't forget that the page that SETS the cookie can't SEE the cookie. (as in, the same section of code that calls cookie() to set a cookie can't then retreive the value by another cookie call, because the values you're retrieving are the cookies that were previously set. Any new cookies can be read on subsequent pages.)

      ... and if you can't find your way to the command-line, you can always double print the header.

      # I use text/plain because it makes # content look like 'view source', but # it isn't necessary. print header( 'text/plain' ); # Since we've already printed a header, # this one gets printed to the browser # screen instead. print header( -cookie => $cookie );

          --k.


Re: General cookie information
by dws (Chancellor) on Apr 16, 2002 at 22:03 UTC
    To further my understanding, what exact text is being sent to the browser in the entireity of this code?

    I see this question has been satisfactorily answered, and will add that if you're going to be playing the HTTP game at this level, one valuable resource to have on hand is O'Reilly's Webmaster in a Nutshell. There you'll find, among other things, a good description of the HTTP protocol, including details on the various headers.

    I keep a copy within reach at home and at work.

159669
by Samn (Monk) on Apr 16, 2002 at 23:05 UTC
    A reply falls below the community's threshold of quality. You may see it by logging in.