YATT::Lite::WebMVC0::Partial::Session2 -- (Revised) Session support for YL
In app.psgi:
use YATT::Lite::WebMVC0::SiteApp -as_base; # As usual. # # Below imports definitions of &yatt:session_start(); and # session_state/session_store options with multiple inheritance. # use YATT::Lite::WebMVC0::Partial::Session2 -as_base; # # Then create site app as usual. # use Plack::Session::State::Cookie (); use Plack::Session::Store::DBI (); # my MY $site = MY->load_factory_for_psgi( $0, doc_root => "$FindBin::Bin/public", session_state => Plack::Session::State::Cookie->new(), session_store => [DBI => get_dbh => sub { DBI->connect(...) } ], ); # return $site->to_app;
In *.yatt:
&yatt:session_start(); # Optional <h2>Hello &yatt:psgix_session(){user};</h2>
This module is a session plugin for site apps of YATT::Lite, based on Plack::Session family.
Internally, it creates Plack::Middleware::Session at startup. Then it emulates Plack::Middleware::Session#get_session on each call to &yatt:session_start(); and emulates Plack::Middleware::Session#finalize on response finalization.
Plack::Middleware::Session#get_session
Plack::Middleware::Session#finalize
Following options are imported to the site app.
Plack::Session::State::Cookie
[$NAME => @ARGS]
This option can take one value of following two types:
[$NAME, @ARGS]
In this case, $NAME is used to load specific session state class using Plack::Util::load_class($NAME, 'Plack::Session::State').
$NAME
If no option is provided the default Plack::Session::State::Cookie will be used.
Plack::Session::Store
In this case, $NAME is used to load specific session state class using Plack::Util::load_class($NAME, 'Plack::Session::Store').
If no option is provided the default Plack::Session::Store will be used.
Explicitly start session. psgix_session calls this automatically.
Extract state id from cookie without starting session. Returns undef if not exists.
Test if session state id exists.
psgix.session
$env->{psgix.session}
$env->{psgix.session.options}
$env->{psgix.session.options}{id}
plack.session
$env->{plack.session}
Plack::Session->id()
Plack::Session->get()
Plack::Session->set()
Plack::Session->remove()
Plack::Session->keys()
Plack::Session->expire()
Plack::Session::State::Cookie, Plack::Session::Store
hkoba
To install YATT::Lite, copy and paste the appropriate command in to your terminal.
cpanm
cpanm YATT::Lite
CPAN shell
perl -MCPAN -e shell install YATT::Lite
For more information on module installation, please visit the detailed CPAN module installation guide.