what if thats not the only cookie?
If the name of the cookie you created is 'sessionid' you can read the value of the cookie into a variable as follows:
use CGI qw(:standard -debug);
use CGI::Carp qw(fatalsToBrowser);
#Create a new CGI object
my $cgi = new CGI;
my $value=$cgi->cookie('sessionid');
If no cookie named 'sessionid' exists, your $value variable will have no value assigned to it.
d5e5
Practically a Posting Shark
810 posts since Sep 2009
Reputation Points: 159
Solved Threads: 159
I suppose you could do it like this:
#!/usr/bin/perl
use strict;
use warnings;
use 5.008;
use CGI qw(:standard);
my $name_to_search = 'sessionid';
my ($n, $v) = find_cookie($name_to_search);
print header();
if ($n eq 'NOTFOUND'){
print "Cookie named '$name_to_search' not found</br>";
}
else{
print "Found cookie named '$n', Value is '$v'</br>";
}
sub find_cookie{
my $name = shift;
my $c = $ENV{HTTP_COOKIE};
my @arr = split(/; /, $c);
foreach (@arr){
my @nv = split(/=/);
next if $nv[0] ne $name;
return @nv;
}
return ('NOTFOUND',"$name cookie not found")
}
d5e5
Practically a Posting Shark
810 posts since Sep 2009
Reputation Points: 159
Solved Threads: 159