1 package Plack::Session;
6 our $AUTHORITY = 'cpan:STEVAN';
8 use Plack::Util::Accessor qw( session options );
11 my ($class, $env) = @_;
13 session => $env->{'psgix.session'},
14 options => $env->{'psgix.session.options'},
31 my ($self, $key) = @_;
32 $self->session->{$key};
36 my ($self, $key, $value) = @_;
37 delete $self->options->{no_store};
38 $self->session->{$key} = $value;
42 my ($self, $key) = @_;
43 delete $self->options->{no_store};
44 delete $self->session->{$key};
49 keys %{$self->session};
52 ## Lifecycle Management
56 for my $key ($self->keys) {
57 delete $self->session->{$key};
59 $self->options->{expire} = 1;
70 Plack::Session - Middleware for session management
74 # Use with Middleware::Session
81 my $session = Plack::Session->new($env);
85 $session->set($key, $value);
86 $session->remove($key);
94 This is the core session object, you probably want to look
95 at L<Plack::Middleware::Session>, unless you are writing your
96 own session middleware component.
102 =item B<new ( $env )>
104 The constructor takes a PSGI request env hash reference.
108 This is the accessor for the session id.
112 =head2 Session Data Management
114 These methods allows you to read and write the session data like
119 =item B<get ( $key )>
121 =item B<set ( $key, $value )>
123 =item B<remove ( $key )>
127 =item B<session>, B<dump>
131 =head2 Session Lifecycle Management
137 This method can be called to expire the current session id.
143 All complex software has bugs lurking in it, and this module is no
144 exception. If you find a bug please either email me, or add the bug
149 Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
151 =head1 COPYRIGHT AND LICENSE
153 Copyright 2009, 2010 Infinity Interactive, Inc.
155 L<http://www.iinteractive.com>
157 This library is free software; you can redistribute it and/or modify
158 it under the same terms as Perl itself.