NAME

Catalyst::Plugin::Session::AsObject - Make your session data an object

VERSION

version 0.05

SYNOPSIS

package MyApp;

use MyApp::Session;

use Catalyst qw(
    Session
    Session::AsObject
    Session::Store::DBI
    Session::State::Cookie
);

__PACKAGE__->config(
    'Plugin::Session' => {
        ...,
        object_class => 'MyApp::Session',
    },
);

sub foo : Global {
    my $self = shift;
    my $c    = shift;

    my $session = $c->session_object();

    if ( $session->has_error_messages() ) {...}
}

DESCRIPTION

This class makes it easier to treat the session as an object rather than a plain hash reference. This is useful if you want to ensure that the session only contains specific pieces of data.

However, because of implementation details, we cannot override the existing $c->session() method, so you need to use the new $c->session_object() method provided by this plugin.

METHODS

This class provides the following methods:

$c->session_object()

Returns the object stored in the session. If needed, a new object is created.

$c->has_session_object()

Returns true if there is an object already in the session.

CONFIG

This plugin has only configuration key, "object_class". This key should appear under the existing top-level "session" configuration key.

The "object_class" must already be loaded, and must have a new() method as its constructor. This constructor must not require any parameters, as it will be called without any arguments.

BUGS

Please report any bugs or feature requests to bug-catalyst-plugin-sessionasobject@rt.cpan.org, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

DONATIONS

If you'd like to thank me for the work I've done on this module, please consider making a "donation" to me via PayPal. I spend a lot of free time creating free software, and would appreciate any support you'd care to offer.

Please note that I am not suggesting that you must do this in order for me to continue working on this particular software. I will continue to do so, inasmuch as I have in the past, for as long as it interests me.

Similarly, a donation made in this way will probably not make me work on this software much more, unless I get so many donations that I can consider working on free software full time, which seems unlikely at best.

To donate, log into PayPal and send money to autarch@urth.org or use the button on this page: http://www.urth.org/~autarch/fs-donation.html

AUTHOR

Dave Rolsky, >autarch@urth.org<

COPYRIGHT AND LICENSE

This software is Copyright (c) 2012 by Dave Rolsky.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)