Apache2-WebApp-Plugin-Session

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

  create
    Create a new session.

    By default, when a new session is created, a browser cookie is set that
    contains a "session_id". Upon success, this session identifier is
    returned, which can also be used to set a customized session cookie.

      my $session_id = $c->plugin('Session')->create($c, 'login',
          {
              username => 'foo',
              password => 'bar',
          }
        );

  get
    Takes the cookie unique identifier or session id as arguments. Returns
    the session data as a hash reference.

      my $data_ref = $c->plugin('Session')->get($c, 'login');

      print $data_ref->{username};     # outputs 'foo'

README  view on Meta::CPAN


EXAMPLE
      package Example;

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

          $c->plugin('Session')->create($c, 'login',
              {
                  username => 'foo',
                  password => 'bar',
              }
            );

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

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

          my $data_ref = $c->plugin('Session')->get($c, 'login');

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

          print $data_ref->{username} . '-' . $data_ref->{password};     # outputs 'foo-bar'
      }

      1;

SUPPORTED TYPES
    Apache2::WebApp::Plugin::Session::File
    Apache2::WebApp::Plugin::Session::Memcached
    Apache2::WebApp::Plugin::Session::MySQL

SEE ALSO

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


Create a new session.

By default, when a new session is created, a browser cookie is set that contains 
a C<session_id>.  Upon success, this session identifier is returned, which can 
also be used to set a customized session cookie.

  my $session_id = $c->plugin('Session')->create($c, 'login',
      {
          username => 'foo',
          password => 'bar',
      }
    );

=head2 get

Takes the cookie unique identifier or session id as arguments.  Returns the 
session data as a hash reference. 

  my $data_ref = $c->plugin('Session')->get($c, 'login');

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

=head1 EXAMPLE

  package Example;

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

      $c->plugin('Session')->create($c, 'login',
          {
              username => 'foo',
              password => 'bar',
          }
        );

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

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

      my $data_ref = $c->plugin('Session')->get($c, 'login');

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

      print $data_ref->{username} . '-' . $data_ref->{password};     # outputs 'foo-bar'
  }

  1;

=head1 SUPPORTED TYPES

Apache2::WebApp::Plugin::Session::File
Apache2::WebApp::Plugin::Session::Memcached
Apache2::WebApp::Plugin::Session::MySQL



( run in 0.636 second using v1.01-cache-2.11-cpan-49f99fa48dc )