Gossamer Forum
Home : General : Perl Programming :

Can anyone figure this out...

Quote Reply
Can anyone figure this out...
I am trying to set a cookie in someones browser and then forward them to another page...this is the code I am using and when you visit the script it does what it is supposed to and forwards you to the correct page...

#!/usr/bin/perl

use CGI;
use CGI qw/:standard/;
use CGI::Cookie;


&cook();

sub cook {
my $in = new CGI;
my $re = $ENV{'HTTP_REFERER'};
my $cookie = $in->cookie ( -name => 'ref',
-value => $re, );

print $in->header ( -cookie => $cookie );
print qq|
<html>
<head>
<META HTTP-EQUIV="Refresh" CONTENT="0;URL=http://www.audio-grabber.com/domains/">
</head>
<body>
</body>
</html>
|;

}



....then when the person signs up for one of my services on one of my other cgi pages, I want the value of the cookie to be emailed to me with the rest of the registration details, so I have used...

$value=cookie('ref');

open mail...blabla...
print MAIL "Referer: $value";


......but all I see is Referer:

Just a blank space........what have I done wrong?

THANKYOU!

Paul Wilson. Shocked
(Dont blame me if I'm wrong!)
Quote Reply
Re: Can anyone figure this out... In reply to
Code:
#!/usr/bin/perl

use CGI;

my $in = new CGI;
cook ($in);

sub cook {
my $in = shift;
my $cookie = $in->cookie (
-name => 'ref',
-value => $ENV{'HTTP_REFERER'},
-path => '/'
);
print $in->redirect(
-cookie => $cookie,
-uri => "http://www.audio-grabber.com/domains/"
);
}
also.. in the other script.. use CGI.. not CGI::cookie and use

my $value = $in->cookie ('ref');

spares the extra modules

Jerry Su
widgetz sucks
Quote Reply
Re: Can anyone figure this out... In reply to
Thankyou very much Jerry...

There seems to be so many different ways of writing things that is so easy for people like me to get it wrong!....lol


Paul Wilson. Shocked
(Dont blame me if I'm wrong!)
Quote Reply
Re: Can anyone figure this out... In reply to
That still doesnt seem to be working....

I am still getting a blank space where the referer should be....(my browser is setup to accept cookies too).

Paul Wilson. Shocked
(Dont blame me if I'm wrong!)