Setting cookie with CGI.pm

by Hwg <hwg(at)soundhouse.co.uk>

 Date:  Wed, 04 Apr 2001 20:00:27 +0100
 To:  hwg-languages(at)mail.hwg.org
 References: 
  todo: View Thread, Original
I'm trying to set a cookie using CGI.pm and the following code but it
doesn't appear to be working. Each time it prints 'Cookie not detected...'
and the cookie doesn't appear to have been set in the browser. 

If anybody could point me in the right direction I'd be most grateful.

#!/usr/bin/perl -w

$require_dir = '/home/soundh/cgi-bin/required';

if ($require_dir ne '') {
    push(@INC, $require_dir);
}

use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);
use strict;

$CGI::POST_MAX=1024 * 1000; # max 1000K posts
$CGI::DISABLE_UPLOADS=1; # no uploads

my $cookie= cookie(
    -name => 'cookie_test',
    -value => 1,
);                         


my %cookie = cookie('cookie_test');
my $value = $cookie{'value'};

if ($value eq 1){
    print header;
    print 'Cookie detected<br>';
    }
else {
    print header(
        -cookie => $cookie,
    );
    print 'Cookie not detected, now set<br>';
}

-- 
Geoff Soper
Soundhouse webmaster
webmaster(at)soundhouse.co.uk

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA