12 use Plack::Session::State;
13 use Plack::Session::Store;
16 open my $in, '<', \do { my $d };
18 'psgi.version' => [ 1, 0 ],
20 'psgi.errors' => *STDERR,
21 'psgi.url_scheme' => 'http',
23 REQUEST_METHOD => 'GET',
25 my $r = Plack::Request->new( $env );
30 my $storage = Plack::Session::Store->new;
31 my $state = Plack::Session::State->new;
36 my $s = Plack::Session->new(
42 is($s->id, 1, '... got a basic session id (1)');
44 ok(!$s->get('foo'), '... no value stored in foo for session (1)');
47 $s->set( foo => 'bar' );
48 } '... set the value successfully in session (1)';
50 is($s->get('foo'), 'bar', '... got the foo value back successfully from session (1)');
52 my $resp = $r->new_response;
55 $s->finalize( $resp );
56 } '... finalized session (1) successfully';
62 my $s = Plack::Session->new(
68 is($s->id, 2, '... got a basic session id (2)');
70 ok(!$s->get('foo'), '... no value stored for foo in session (2)');
73 $s->set( foo => 'baz' );
74 } '... set the value successfully';
76 is($s->get('foo'), 'baz', '... got the foo value back successfully from session (2)');
78 my $resp = $r->new_response;
81 $s->finalize( $resp );
82 } '... finalized session (2) successfully';
86 my $r = request({ plack_session => 1 });
88 my $s = Plack::Session->new(
94 is($s->id, 1, '... got a basic session id (1)');
96 is($s->get('foo'), 'bar', '... got the value for foo back successfully from session (1)');
100 } '... removed the foo value successfully from session (1)';
102 ok(!$s->get('foo'), '... no value stored for foo in session (1)');
104 my $resp = $r->new_response;
107 $s->finalize( $resp );
108 } '... finalized session (1) successfully';
113 my $r = request({ plack_session => 2 });
115 my $s = Plack::Session->new(
121 is($s->id, 2, '... got a basic session id (2)');
123 is($s->get('foo'), 'baz', '... got the foo value back successfully from session (2)');
125 my $resp = $r->new_response;
128 $s->finalize( $resp );
129 } '... finalized session (2) successfully';
133 my $r = request({ plack_session => 1 });
135 my $s = Plack::Session->new(
141 is($s->id, 1, '... got a basic session id (1)');
143 ok(!$s->get('foo'), '... no value stored for foo in session (1)');
146 $s->set( bar => 'baz' );
147 } '... set the bar value successfully in session (1)';
149 my $resp = $r->new_response;
152 $s->finalize( $resp );
153 } '... finalized session (1) successfully';
157 my $r = request({ plack_session => 1 });
159 my $s = Plack::Session->new(
165 is($s->id, 1, '... got a basic session id (1)');
167 is($s->get('bar'), 'baz', '... got the bar value back successfully from session (1)');
171 } '... expired session (1) successfully';
175 my $r = request({ plack_session => 1 });
177 my $s = Plack::Session->new(
183 is($s->id, 3, '... got a new session id (3)');
185 ok(!$s->get('bar'), '... no bar value stored (from session (1)) in session (3)');
189 my $r = request({ plack_session => 2 });
191 my $s = Plack::Session->new(
197 is($s->id, 2, '... got a basic session id (2)');
199 is($s->get('foo'), 'baz', '... got the foo value back successfully from session (2)');
201 my $resp = $r->new_response;
204 $s->finalize( $resp );
205 } '... finalized session (2) successfully';