PDA

View Full Version : Neww to perl need help, please


Charles_cz
01-01-2004, 04:24 AM
Hi I am new to perl and I need your help. I can't figure out how to read cookies. It's probably very simple.

I have existing simple cookie with name User and value Mark.

I have script:

#!/usr/bin/perl
use CGI;
my $query = new CGI;
my $cookie_in = $query->cookie('User');
print "Content-type: text/html\n\n";
print "Value is $cookie_in";
exit;


If I execute script as part of *.shtml page

<!--#exec cgi="/cgi-bin/SSI-LastName.cgi"--> I will get cookie value as I need. No problem there,

If I run the same script it self it will display blank page. It will not find the cookie. What do I have to do if I want to read cookie "User" in perl script and use value somwhere else in the script.

Why script can not read cookies unless I execute it in shtml file?

I really need help because I am new to cookies and I know just a little bit about perl.

Thank you Charles

mlseim
01-01-2004, 07:12 PM
Many people use the "cookie.lib" perl library file to handle
cookies ... here's the link with file and documentation:

http://www.scriptarchive.com/cookielib.html

I've used it and it works good. I just want to hear from some
Perl Experts on this forum as to what THEY think of it.
Is it secure?, bug-free?, etc.?

I just know it makes handling cookies easy.

--Max

Jeff Mott
01-02-2004, 09:10 AM
Nothing from matt's scripts have ever been held in high regard. Even matt no longer recommends his scripts (http://www.scriptarchive.com/nms.html).Matt Wright
The code you find at Matt's Script Archive is not representative of how even I would code these days.And CGI module is just as easy, and most likely better way for retrieving cookies.

If the original poster's page is coming back completely blank (also missing the "Value of " string) then it is not a problem with the cookies. But perhaps something misconfigured on the server.