Name

set_cookie

Synopsis

$cjar->set_cookie(version, key, val, path, domain, port, path_spec, secure, maxages, discard, \%misc)

Sets a cookie in the cookie jar with the information given in the arguments. The number and order of arguments represent the structure of elements in the Set-Cookie3 header lines used to save the cookies in a file.

version

A string containing the cookie-spec version number.

key

The name of the cookie.

val

The value of the cookie.

path

The pathname of the URL for which the cookie is set.

domain

The domain name for which the cookie is set.

port

The port number of the URL for which the cookie is set.

path_spec

A Boolean value indicating if the cookie is valid for the specific URL path or all the URLs in the domain. The path is used if true; otherwise, the cookie is valid for the entire domain.

secure

A Boolean value indicating that the cookie should only be sent over a secure connection for true, or over any connection for false.

maxage

The number of seconds that the cookie will be valid from the time it was received. Adding the maxage to the current time will yield a value that can be used for an expiration date.

discard

A Boolean value indicating that the cookie should not be sent in any future requests and should be discarded upon saving the cookie jar, unless the ignore_discard parameter was set to true in the constructor.

% misc

The final argument is a reference to a hash, % misc, that contains any additional parameters from the Set-Cookie headers such as Comment and URLComment, ...

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.