From 1a70068ffe0160d80d92e658dd9132b4b3f5c1fd Mon Sep 17 00:00:00 2001 From: Akzhan Abdulin Date: Sun, 25 Jun 2017 14:38:48 +0300 Subject: [PATCH] Add session management. --- config/defaults.yml | 2 ++ script/http.pl | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/config/defaults.yml b/config/defaults.yml index 82985b6..3acd584 100644 --- a/config/defaults.yml +++ b/config/defaults.yml @@ -6,6 +6,8 @@ app: port: 7777 workers: 1 backlog: 128 + session: + expire: 2419200 # 4 weeks database: host: localhost name: yourdatabase diff --git a/script/http.pl b/script/http.pl index ff60b06..01d7794 100644 --- a/script/http.pl +++ b/script/http.pl @@ -2,9 +2,17 @@ use Plack::Handler::Starman; use Plack::Builder; +use Plack::Session::State::Cookie; +use Plack::Session::Store::RedisFast; my $app = Plack::Util::load_psgi "./script/cli"; builder { + enable 'Session', + state => Plack::Session::State::Cookie->new( + expires => YourCompany::Config->app->{session}{lifetime} ), + store => Plack::Session::Store::RedisFast->new( + expires => YourCompany::Config->app->{session}{lifetime} ); + $app; };