NAME
YATT::Lite::WebMVC0::Partial::Session2 -- (Revised) Session support for YL
SYNOPSIS
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>
DESCRIPTION
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.
OPTIONS
Following options are imported to the site app.
session_state = Plack::Session::State::Cookie
| [$NAME => @ARGS]
This option can take one value of following two types:
- An instance of Plack::Session::State::Cookie compatible object.
- An ARRAY which consists of
[$NAME, @ARGS]
-
In this case,
$NAME
is used to load specific session state class using Plack::Util::load_class($NAME, 'Plack::Session::State').
If no option is provided the default Plack::Session::State::Cookie will be used.
session_store = Plack::Session::Store
| [$NAME => @ARGS]
This option can take one value of following two types:
- An instance of Plack::Session::Store compatible object.
- An ARRAY which consists of
[$NAME, @ARGS]
-
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.
session_middleware_class = $CLASS_NAME
ENTITY FUNCTIONS
session_start
Explicitly start session. psgix_session calls this automatically.
session_state_id
Extract state id from cookie without starting session. Returns undef if not exists.
session_state_exists
Test if session state id exists.
Raw psgix.session
interface
psgix_session
$env->{psgix.session}
psgix_session_options
$env->{psgix.session.options}
psgix_session_exists
$env->{psgix.session.options}{id}
plack.session
(Plack::Session) interface
session
$env->{plack.session}
session_id
session_get
session_set
session_remove
session_keys
session_expire
SEE ALSO
Plack::Session::State::Cookie, Plack::Session::Store
AUTHOR
hkoba