1Plack::Session::Store::UFsielre(C3opnmt)ributed Perl DocPulmaecnkt:a:tSieosnsion::Store::File(3pm)
2
3
4
6 Plack::Session::Store::File - Basic file-based session store
7
9 use Plack::Builder;
10 use Plack::Middleware::Session;
11 use Plack::Session::Store::File;
12
13 my $app = sub {
14 return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'Hello Foo' ] ];
15 };
16
17 builder {
18 enable 'Session',
19 store => Plack::Session::Store::File->new(
20 dir => '/path/to/sessions'
21 );
22 $app;
23 };
24
25 # with custom serializer/deserializer
26
27 builder {
28 enable 'Session',
29 store => Plack::Session::Store::File->new(
30 dir => '/path/to/sessions',
31 # YAML takes it's args the opposite order
32 serializer => sub { YAML::DumpFile( reverse @_ ) },
33 deserializer => sub { YAML::LoadFile( @_ ) },
34 );
35 $app;
36 };
37
39 This implements a basic file based storage for session data. By default
40 it will use Storable to serialize and deserialize the data, but this
41 can be configured easily.
42
43 This is a subclass of Plack::Session::Store and implements its full
44 interface.
45
47 new ( %params )
48 The %params can include dir, serializer and deserializer options.
49 It will check to be sure that the dir is writeable for you.
50
51 dir This is the directory to store the session data files in, if
52 nothing is provided then "/tmp" is used.
53
54 serializer
55 This is a CODE reference that implements the serialization logic.
56 The CODE ref gets two arguments, the $value, which is a HASH
57 reference to be serialized, and the $file_path to save it to. It
58 is not expected to return anything.
59
60 deserializer
61 This is a CODE reference that implements the deserialization logic.
62 The CODE ref gets one argument, the $file_path to load the data
63 from. It is expected to return a HASH reference.
64
66 All complex software has bugs lurking in it, and this module is no
67 exception. If you find a bug please either email me, or add the bug to
68 cpan-RT.
69
71 Stevan Little <stevan.little@iinteractive.com>
72
74 Copyright 2009, 2010 Infinity Interactive, Inc.
75
76 <http://www.iinteractive.com>
77
78 This library is free software; you can redistribute it and/or modify it
79 under the same terms as Perl itself.
80
81
82
83perl v5.36.0 2022-07-22 Plack::Session::Store::File(3pm)