Huzoor Bux
Huzoor Bux

Reputation: 1048

My CGI script cookie set and get

I have a site on CGI and working fine yesterday but suddenly its cookie stop working. I am unable to set cookie and get cookie in my script. below is my code.

To set cookie

#!/usr/bin/perl
use CGI::Carp qw (fatalsToBrowser);
use CGI;
require "cookie.lib";
&SetCookies('V', $EncUID);

To get cookie

#!/usr/bin/perl
use CGI::Carp qw (fatalsToBrowser);
use CGI;
require "cookie.lib";
&GetCookies();
my $UID = $Cookies{"V"};

Please Help me regarding this.

Upvotes: 2

Views: 2878

Answers (1)

daxim
daxim

Reputation: 39158

Whoa, it's suddenly like 199x all over. Replace cookie.lib with CGI::Cookie.

#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
use CGI;
use CGI::Cookie qw();

print CGI::header(-cookie => [CGI::Cookie->new(-name => 'V',-value => $EncUID)]);

#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
use CGI;
use CGI::Cookie qw();

my %cookies = CGI::Cookie->fetch;
my $UID = $cookies{'V'}->value;

Upvotes: 4

Related Questions