OpenInteract::Cookies::Apache - handler to parse/output cookies from/to the client using Apache::Cookie
# In your website's 'conf/server.perl' file: # Use Apache::Cookie (from Apache::Request) 'system_alias' => { cookies => 'OpenInteract::Cookies::Apache', ... } # Retrieve the cookies from the client request $R->cookies->parse; # Place cookies in the outbound content header $R->cookies->bake; # Retrieve a cookie value in an OpenInteract content handler $params->{search} = $R->{cookie}{in}{search_value}; # Create a new cookie $R->cookies->create_cookie({ name => 'search_value', expires => '+3M', value => 'this AND that' }); # Expire an old cookie $R->cookies->create_cookie({ name => 'search_value', expires => '-3d', value => undef });
This module defines methods for retrieving, setting and creating cookies. If you do not know what a cookie is, check out:
http://www.ics.uci.edu/pub/ietf/http/rfc2109.txt
OpenInteract currently uses one of two modules to perform these actions. They adhere to the same interface but perform the actions using different helper modules. This module uses Apache::Cookie to do the actual cookie actions.
Note that Apache::Cookie does not work on all platforms, particularly Win32 (as of this writing). If Apache::Cookie does not work for you, please use the OpenInteract::Cookies::CGI module instead.
To use this implementation, set the following key in the conf/server.perl file for your website:
conf/server.perl
system_aliases => { cookies => 'OpenInteract::Cookies::Apache', ... },
Methods for this class.
create_cookie( \%params )
This function is probably the only one you will ever use from this module. Pass in normal parameters (see below) and the function will create a cookie and put it into $R for you.
Parameters:
name ($) (required)
Name of cookie
value ($ (required)
Value of cookie
expires ($ (optional)
When it 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 her browser.
path ($) (optional)
Path it responds to
parse()
Read in the cookies passed to this request and file them into the hashref:
$R->{cookie}{in}
with the key as the cookie name.
bake()
Puts the cookies from $R->{cookie}->{out} into the outgoing headers.
Nothing.
None known.
Apache::Cookie
Copyright (c) 2001-2002 intes.net, inc.. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Chris Winters <chris@cwinters.com>
To install OpenInteract, copy and paste the appropriate command in to your terminal.
cpanm
cpanm OpenInteract
CPAN shell
perl -MCPAN -e shell install OpenInteract
For more information on module installation, please visit the detailed CPAN module installation guide.