NAME

Plasp::Session - Default class for $Session objects

SYNOPSIS

package MyApp;

use Moo;

sub BUILD {
  my ( $self, @args ) = @_;

  $self->Session( bless $env->{'psgix.session'}, 'Plasp::Session' );
};

DESCRIPTION

The $Session object keeps track of user and web client state, in a persistent manner, making it relatively easy to develop web applications.

A Plasp::Session composes the Plasp::State::Session role, which implements the API a $Session object. Please refer to Plasp::State::Session for the $Session API.

Plasp::Session uses the $env->{'psgix.session'} hash provided by Plack. Therefore, further configuration is handled as middleware, in the app.psgi file.

There are thus two options to implementing your own Plasp Session class. You can use this default class, which would rely on Plack::Middleware::Session interface to State and Store. You can then write State and Store classes to define the methods required or you can use a third-party session middleware.

Alternatively, you may write a class replacing Plasp::Session and compose of the Plasp::State::Session role to implement the API for $Session. Overload the methods as necessary. Then configure the application with your custom Session class.

MyApp->config(
  SessionClass  => 'MyApp::Session',
  SessionConfig => {
    myapp_session_config_1 => 'foo',
    myapp_session_config_2 => 'bar',
  },
);

Since Plasp is designed to be a Plack app and utilizes the PSGI 1.1 specification, the former method is recommended. However, you can do both and use a custom class that better fits your needs or is more integrated with Plack::Middleware::Session.

SEE ALSO