#!/usr/bin/perl -w
######################################################################
# cookie.pl
######################################################################
# Perl Power! - Michael Schilli 1998
######################################################################

use CGI qw/:standard/;

if(defined ($val=cookie(-name => 'cook_key'))) {
         
    print header();                  # cookie set,
    print h1("Cookie set: $val");    # output value

} else { 
    $cookie = cookie(                # cookie not set, create
        '-name'    => 'cook_key',    # name of the cookie
        '-value'   => "value!",      # value of the cookie
        '-expires' => '+1h',         # expires after 1 hour
        '-domain'  => '.scamp.com',  # valid for www.scamp.com,
                                     # host.scamp.com etc.
        '-path'    => '/cgi-bin',    # only for CGI scripts
        '-secure'  => 0              # not only for HTTPS servers
    );
    print header('-cookie' => $cookie);
    print h1("Cookie transmitted!");
}

