cgi / cookie help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Joe

    cgi / cookie help

    I want to be able to detect if I can write cookies out or not.

    Currently I'm doing:

    my $cgi = new CGI;

    my $cookie = $cgi->cookie(-name => $POLL_CODE_TEST ,
    -value => "cookietest ",
    -expires => "1d",
    -path => '/',
    -domain => $COOKIE_REALM);

    print $cgi->cookie($POLL_C ODE_TEST);

    Now this doesn't work. Even when you can write out cookies,
    $cgi->cookie($POLL_C ODE_TEST) doesn't give me it back. Now I'm
    guessing that the CGI object doesn't acturally write out the cookies
    until it's destructor... So I tried it in a different scope but that
    didn't work. Maybe I don't understand perl scope, which is very
    possible.
    What am I missing, and is there a better way to test you can write out
    cookies?

    Thankyou for anyhelp.
  • Jim Gibson

    #2
    Re: cgi / cookie help

    In article <6586e7f6.04030 90447.3865b531@ posting.google. com>, Joe
    <jab_joe@www.co m> wrote:
    [color=blue]
    > I want to be able to detect if I can write cookies out or not.
    >
    > Currently I'm doing:
    >
    > my $cgi = new CGI;
    >
    > my $cookie = $cgi->cookie(-name => $POLL_CODE_TEST ,
    > -value => "cookietest ",
    > -expires => "1d",
    > -path => '/',
    > -domain => $COOKIE_REALM);
    >
    > print $cgi->cookie($POLL_C ODE_TEST);
    >
    > Now this doesn't work. Even when you can write out cookies,
    > $cgi->cookie($POLL_C ODE_TEST) doesn't give me it back. Now I'm
    > guessing that the CGI object doesn't acturally write out the cookies
    > until it's destructor... So I tried it in a different scope but that
    > didn't work. Maybe I don't understand perl scope, which is very
    > possible.
    > What am I missing, and is there a better way to test you can write out
    > cookies?[/color]

    Cookies are printed to standard output with the header, i.e. when you
    do:

    print $cgi->header(-cookie=>$cookie );

    If you want to see what you are sending to the client, do

    print $cookie,"\n";

    You can always write out cookies in the header. Whether or not the
    client accepts them and sends them back with subsequent queries is
    something else. You have to check $cgi->cookie("$POLL_ CODE_TEST") in
    the next query in your example to see if you get back what was sent.
    [color=blue]
    >
    > Thankyou for anyhelp.[/color]


    FYI: this newsgroup is defunct. Try comp.lang.perl. misc in the future.

    Comment

    Working...