Gossamer Forum
Home : General : Perl Programming :

Getting a Cookie using SSI's

Quote Reply
Getting a Cookie using SSI's
Hi, I have an extremely simple script which reads a cookie and then prints it.
The script works fine when called from the script path ex:
http://...cgi-bin/test.cgi

But it won't print when called from an SSI.
ex: <!--#INCLUDE virtual="/cgi-bin/test.cgi"-->

Can anyone shed some light on why this doensn't work?

Mucha appreciated,
Kevin


THE SCRIPT (test.cgi)
--------------------------------------------------------
use CGI::Cookie;

### Use this to set the cookie ##############
#%shopcart = (
# this => "that",
# color=> "red"
#);

#$cookie1 = new
CGI::Cookie(-name=>'shopcart',-value=>\%shopcart,-expires=>'+1h');
#print "Set-Cookie: $cookie1\n";
####################################

# fetch existing cookies
%cookies = fetch CGI::Cookie;

%shopcart = $cookies{'shopcart'}->value if ($cookies{'shopcart'});

print "Content-type: text/html\n\n";
print %shopcart;
Quote Reply
Re: Getting a Cookie using SSI's In reply to
Where did you find this script?
maybe there more info about the script on the net? please let me know, im alsow interested!
Quote Reply
Re: Getting a Cookie using SSI's In reply to
Hi, this script comes with the CGI modules (a la CGI.PM), and is usually included in the Perl distribution (It comes with ActiveState's perl).

The problem was that in it's documentation it says that if you do not specify a PATH variable for your cookie, it will default to "\", giving all of the files on your server access to the cookie. This is false, and you in face need to set this variable manually to have it work.

Things work well once this is done.

Ciao
Kevin