in reply to Cookies created via CGI.pm and CGI::Cookie incorrectly made

Cookies go in the header, not after the header. After the \r\n\r\n sequence, it's for the browser to display, not interpret.

print $q->header( -cookie => [ $cookie, $cookie2 ] );

Replies are listed 'Best First'.
Re: Re: Cookies created via CGI.pm and CGI::Cookie incorrectly made
by skazat (Chaplain) on Mar 18, 2003 at 06:48 UTC

    Putting the cookie after the header was a means for me to see what the actual Set-cookie: header would look like, since I don't have shell access to this server.

    The point you make really has nothing to do with why the cookie itself is being written entirely incorrectly, so incorrectly, that my browser won't even accept the cookie.

    I understand how to use the CGI and the CGI::Cookie modules, I just haven't a clue why both of these modules are mucking up so badly

     

    -justin simoni
    !skazat!

      I think he's right. Try it. CGI::Cookie uses some tricky stuff to make the print $cookie possible and it may get messed up after you call the header method. You can debug the headers by using GET -ed http://yourserver.com/ to dump them out. GET is a script that comes with LWP, which you should install if you don't already have it.
      Putting the cookie after the header was a means for me to see what the actual Set-cookie: header would look like, since I don't have shell access to this server.

      In that case, change   print $cookie; to   print $cookie->as_string();

        Hmm, I failed to see that, but it still doesn't make much difference. the as_string() method doesn't seem to be even in the public interface of CGI.pm, I see it in the docs of CGI::Cookie, but it doesn't change anything outputted.

         

        -justin simoni
        !skazat!