NAME
OpenPlugin::Cookie - handler to parse/output cookies from/to the client
SYNOPSIS
# Retrieve the cookies from the client request
$OP->cookies->get_incoming;
# Create a new cookie
$OP->cookies->set_outgoing({
name => 'search_value',
expires => '+3M',
value => 'this AND that',
});
# Expire an old cookie
$OP->cookies->set_outgoing({
name => 'search_value',
expires => '-3d',
value => undef,
});
# The cookies are sent to the browser upon sending the HTTP Header
$OP->httpheader->send_outgoing();
DESCRIPTION
This module defines methods for retrieving and creating cookies. You can find information regarding cookies at the following url:
http://www.ics.uci.edu/pub/ietf/http/rfc2109.txt
METHODS
set_outgoing( \%params )
set( \%params )
This method creates a cookie, which will be sent to the browser at the same time the headers are sent. Pass in normal parameters (see below) and the function will create a cookie for you.
Parameters:
name (required)
Name of cookie
value (required)
Value of cookie
expires (optional)
When the cookie expires ( '+3d', etc.). Note that negative values (e.g., '-3d' will expire the cookie on most browsers. Leaving this value empty or undefined will create a 'short-lived' cookie, meaning it will expire when the user closes their browser.
The following are examples of valid expiration times:
"now" - expire immediately "+180s - in 180 seconds "+2m" - in 2 minutes "+12h" - in 12 hours "+1d" - in 1 day "+3M" - in 3 months "+2y" - in 2 years "-3m" - 3 minutes ago(!)
path (optional)
Path it responds to.
Lets say, for example, that you choose a path "
/cgi-bin
". The browser will only send the cookie back to the server if the url path the browser is calling includes/cgi-bin
.
get_incoming( [ $cookie_name ] )
get( [ $cookie_name ] )
Called with no parameters, get_incoming()
returns a list containing the names of each cookie sent to the server.
Called with one parameter, get_incoming returns a reference to a hash containing the values/parameters for $cookie_name
. See get_incoming
for a list of the parameters this function returns.
set_incoming( \%params )
Typically called internally by the Cookie driver to tell OpenPlugin about the cookies which we were sent. If for some reason you wish to alter cookie information that has already been sent to the server, you can do so with this function.
See the set_outgoing
function for valid parameters for \%params
.
TO DO
See the TO DO section of the <OpenPlugin::Request> plugin.
BUGS
Oddly, expiring of cookies does not seem to work yet.
SEE ALSO
See the individual driver documentation for settings and parameters specific to that driver.
COPYRIGHT
Copyright (c) 2001-2003 Eric Andreychek. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
AUTHORS
Eric Andreychek <eric@openthought.net>