Hi,
Thanks to Paul I could add a crypt-function to the following script. (Thanks, ) Only now still one thing needs to be solved. It's the following:
If a user hits this script with a referer the referer is set. this part works fine (see code explanation) But is NO referer is found a empty cookie is set; in other words the existing one is overwritten with " ". How can I make sure NO cookie is set in that case?
(I don't know how to switch from print $in->header( -cookie => $cookie ); to print $in->header();)
my $in = new CGI;
my $id = $in->param('ID');
my $referer = $ENV{'HTTP_REFERER'} || 'http:// /'; # I use http:// / due to the next line.
my ($value) = $referer =~ m,.+://([^/]+)/.*,; # clean referer into www.domain.com
my $crypt = join ("\-", map { ord } (split //, $value)); # change into number-number-number and so on
if (length($crypt) < 5) { $crypt = ""; } # makes sures that not a space is set, see line 1
my $cookie = $in->cookie(
-name => 'userkey',
-value => $crypt,
-domain => '',
-expires => '+16h',
-path => '/'
);
print $in->header( -cookie => $cookie );
&site_html_detailed_frameset($id);
__END__
Thanks to Paul I could add a crypt-function to the following script. (Thanks, ) Only now still one thing needs to be solved. It's the following:
If a user hits this script with a referer the referer is set. this part works fine (see code explanation) But is NO referer is found a empty cookie is set; in other words the existing one is overwritten with " ". How can I make sure NO cookie is set in that case?
(I don't know how to switch from print $in->header( -cookie => $cookie ); to print $in->header();)
Code:
my $in = new CGI;
my $id = $in->param('ID');
my $referer = $ENV{'HTTP_REFERER'} || 'http:// /'; # I use http:// / due to the next line.
my ($value) = $referer =~ m,.+://([^/]+)/.*,; # clean referer into www.domain.com
my $crypt = join ("\-", map { ord } (split //, $value)); # change into number-number-number and so on
if (length($crypt) < 5) { $crypt = ""; } # makes sures that not a space is set, see line 1
my $cookie = $in->cookie(
-name => 'userkey',
-value => $crypt,
-domain => '',
-expires => '+16h',
-path => '/'
);
print $in->header( -cookie => $cookie );
&site_html_detailed_frameset($id);
__END__