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

I'm using perl to read a javascript cookie. The javascript cookie is created by an html page, and read by a script with a .pl extension. First, can the cookie only be read by the page that created it? Or can a different page read it as long as the path parameters are the same? This code gets internal server error when trying to read a javascript cookie created by another page on the same server, but different directory.
#!/usr/local/bin/perl use CGI; $q = new CGI; $cookie_in = $q->cookie("username"); if($cookie_in) { print $cookie_in; } else { print "Can't find cookie\n"; }
Lisa

Replies are listed 'Best First'.
Re: reading javascript cookie
by Roger (Parson) on Oct 28, 2003 at 00:34 UTC
    You internal error is caused by your lines print "Can't find cookie\n"; and print $cookie_in; in both the cases where cookie is found or not found.

    Why? because you didn't print "Content-type: text/html\n\n";

    Add that to your script and the internal server error will go away.

Re: reading javascript cookie
by Anonymous Monk on Oct 28, 2003 at 01:13 UTC