CGI::Cookie

Provides an interface to Netscape (HTTP/1.1) cookies that can be used in conjunction with CGI.pm or independently. To use CGI::Cookie, create a new cookie object with the constructor new. You can then send the cookie to the browser in one of the following ways:

  • From a CGI script, create a Set-Cookie field in the HTTP header for each cookie you want to send ($c is the cookie object):

    print "Set-Cookie: $c0";
  • With CGI.pm (see Chapter 10), use the header method with a -cookie argument:

    print header(-cookie=>$c);
  • Using mod_perl (see Chapter 11), use the request object’s header_out method:

    $r->header_out('Set-Cookie',$c);

    The following methods are provided for CGI::Cookie.

Get Perl in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.