Apache2-WebApp-Plugin-Cookie

 view release on metacpan or  search on metacpan

lib/Apache2/WebApp/Plugin/Cookie.pm  view on Meta::CPAN


  $ perl -MCPAN -e shell
  cpan> install Apache2::WebApp::Plugin::Cookie
  cpan> quit

Just like the manual installation of Perl modules, the user may need root access during
this process to insure write permission is allowed within the installation directory.

=head1 CONFIGURATION

In order to set a browser cookie, you need to specify a valid hostname in your I<webapp.conf>

  [apache]
  domain = www.domain.com

=head1 OBJECT METHODS

=head2 set

Set a new browser cookie.

  $c->plugin('Cookie')->set( $c, {
        name    => 'foo',
        value   => 'bar',
        expires => '24h',
        domain  => 'www.domain.com',    # optional
        secure  => 0,
    });

=head2 get

Return the browser cookie value.

  my $result = $c->plugin('Cookie')->get($name);

  # bar is value of $result

=head2 delete

Delete a browser cookie by name.

  $c->plugin('Cookie')->delete( \%controller, $name );

=head1 EXAMPLE

  package Example;

  use strict;
  use warnings;

  sub _default {
      my ( $self, $c ) = @_;

      $c->plugin('Cookie')->set( $c, {
          name    => 'foo',
          value   => 'bar',
          expires => '1h',
          secure  => 0,
        });

      $c->plugin('CGI')->redirect( $c, '/app/example/verify' );
  }

  sub verify {
      my ( $self, $c ) = @_;

      $c->request->content_type('text/html');

      print $c->plugin('Cookie')->get('foo');
  }

  1;

=head1 SEE ALSO

L<Apache2::WebApp>, L<Apache2::WebApp::Plugin>, L<Apache2::Cookie>

=head1 AUTHOR

Marc S. Brooks, E<lt>mbrooks@cpan.orgE<gt> - L<http://mbrooks.info>

=head1 COPYRIGHT

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

See L<http://dev.perl.org/licenses/artistic.html>

=cut



( run in 1.389 second using v1.01-cache-2.11-cpan-13bb782fe5a )