Giter VIP home page Giter VIP logo

plack-middleware-session's Introduction

NAME

Plack::Middleware::Session - Middleware for session management

SYNOPSIS

use Plack::Builder;

my $app = sub {
    my $env = shift;
    my $session = $env->{'psgix.session'};
    return [
        200,
        [ 'Content-Type' => 'text/plain' ],
        [ "Hello, you've been here for ", $session->{counter}++, "th time!" ],
    ];
};

builder {
    enable 'Session';
    $app;
};

# Or, use the File store backend (great if you use multiprocess server)
# For more options, see perldoc Plack::Session::Store::File
builder {
    enable 'Session', store => 'File';
    $app;
};

DESCRIPTION

This is a Plack Middleware component for session management. By default it will use cookies to keep session state and store data in memory. This distribution also comes with other state and store solutions. See perldoc for these backends how to use them.

It should be noted that we store the current session as a hash reference in the psgix.session key inside the $env where you can access it as needed.

NOTE: As of version 0.04 the session is stored in psgix.session instead of plack.session.

State

  • Plack::Session::State

    This will maintain session state by passing the session through the request params. It does not do this automatically though, you are responsible for passing the session param.

  • Plack::Session::State::Cookie

    This will maintain session state using browser cookies.

Store

  • Plack::Session::Store

    This is your basic in-memory session data store. It is volatile storage and not recommended for multiprocessing environments. However it is very useful for development and testing.

  • Plack::Session::Store::File

    This will persist session data in a file. By default it uses Storable but it can be configured to have a custom serializer and deserializer.

  • Plack::Session::Store::Cache

    This will persist session data using the Cache interface.

  • Plack::Session::Store::Null

    Sometimes you don't care about storing session data, in that case you can use this noop module.

OPTIONS

The following are options that can be passed to this module.

PLACK REQUEST OPTIONS

In addition to providing a psgix.session key in $env for persistent session information, this module also provides a psgix.session.options key which can be used to control the behavior of the module per-request. The following sub-keys exist:

  • change_id

    If set to a true value, forces the session identifier to change (rotate). This should always be done after logging in, to prevent session fixation attacks from subdomains; see http://en.wikipedia.org/wiki/Session_fixation#Attacks_using_cross-subdomain_cooking

  • expire

    If set to a true value, expunges the session from the store, and clears the state in the client.

  • no_store

    If set to a true value, no changes made to the session in this request will be saved to the store. Either "expire" and "change_id" take precedence over this, as both need to update the session store.

  • late_store

    If set to a true value, the session will be saved at the end of the request, after all data has been sent to the client -- this may be required if streaming responses attempt to alter the session after the header has already been sent to the client. Note, however, that it introduces a possible race condition, where the server attempts to store the updated session before the client makes the next request. For redirects, or other responses on which the client needs do minimal processing before making a second request, this race is quite possible to win -- causing the second request to obtain stale session data.

  • id

    This key contains the session identifier of the session. It should be considered read-only; to generate a new identifier, use "change_id".

BUGS

All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT.

AUTHOR

Tatsuhiko Miyagawa

Stevan Little [email protected]

COPYRIGHT AND LICENSE

Copyright 2009, 2010 Infinity Interactive, Inc.

http://www.iinteractive.com

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

plack-middleware-session's People

Contributors

alexmv avatar cho45 avatar fcuny avatar fschlich avatar haarg avatar jkeenan avatar kazeburo avatar leedo avatar lestrrat avatar manwar avatar markstos avatar miyagawa avatar oalders avatar s-aska avatar snakpak avatar tokuhirom avatar vividsnow avatar wchristian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

plack-middleware-session's Issues

move the repository to plack organization

@stevan could you move the repository to @plack organization using GitHub's admin panel? I can fork and make one, but then we'll lose the redirects. While we're at it, would be nice to normalize the case of the repo i.e. plack/Plack-Middleware-Session. Thanks!

t/015_cookie_options_mw.t fails (with old Cookie::Baker?)

On some of my smokers:

#   Failed test at t/015_cookie_options_mw.t line 28.
#                   'plack_session=7d26f1415920ef507a3a0634cda6d5a9ef18a44b; domain=.example.com; HttpOnly'
#     doesn't match '(?^:plack_session=\w+; domain=.example.com; SameSite=Lax; HttpOnly)'

#   Failed test at t/015_cookie_options_mw.t line 31.
#                   'plack_session=36114f09eee2b6d6b8c705e43dbe63aff8876524; domain=.example.com; path=/foo; HttpOnly'
#     doesn't match '(?^:plack_session=\w+; domain=.example.com; path=/foo; SameSite=Lax; HttpOnly)'
# Looks like you failed 2 tests of 2.
t/015_cookie_options_mw.t ...... 
Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/2 subtests 

Statistical analysis suggests that the test passes only with Cookie::Baker 0.10, but not with older versions:

****************************************************************
Regression 'mod:Cookie::Baker'
****************************************************************
Name           	       Theta	      StdErr	 T-stat
[0='const']    	     -0.0000	      0.0000	  -1.88
[1='eq_0.07']  	      0.0000	      0.0000	   1.53
[2='eq_0.08']  	      0.0000	      0.0000	   1.71
[3='eq_0.09']  	      0.0000	      0.0000	   1.75
[4='eq_0.10']  	      1.0000	      0.0000	8092369988423548.00

R^2= 1.000, N= 102, K= 5
****************************************************************

Add hooks to indicate whether a session should be given/updated

For websites, giving a session cookie and inserting/updating session data for every page hit is unnecessary, and even adds too much load for high traffic sites.

There should be a hook that tells the session state whether to send a cookie, and tells the session store whether the session should be created or updated. By default, these methods would always be true, but one should be able to set a flag to check the session for any actual changes.

In 0.26, sessions are saved too late

In 0.26, the Session is stored during the cleanup phase. I understand that this is necessary in cases where the application returns a streaming response and it may well be modifying session data after the initial return. It does create a problem, though: there's now a race condition between the server and the client, in the case of pre-forking / non-blocking servers. This is what happens:

  • the client requests /foo
  • the application on server process 1 stores data in the session, and redirects to /bar
  • the client sees the 302 and Location header, and requests /bar
  • server process 1 is saving the session
  • server process 2 answer the request to /bar, and loads the previous version of the session
  • bad things happen

Could we save the session twice, once directly in the response callback (like 0.25 did), and then in cleanup?

Recreating cookies with per-request values isn't documented

It's possible to recreate cookies with per-request values by setting change_id and one of the following keys in $env->{'psgix.session.options'}:

  • path
  • domain
  • expires
  • secure
  • httponly

This is useful to implement things like a "Remember me" option, for example, so I think it should be documented.

test requires LWP::UserAgent and HTTP::Cookies

Here is output.

% cpanm -v Plack::Middleware::Session
cpanm (App::cpanminus) 1.6922 on perl 5.018000 built for darwin-2level
Work directory is /Users/skaji/.cpanm/work/1372077695.11643
You have make /usr/bin/make
You have /usr/local/bin/wget
You have /usr/bin/tar: bsdtar 2.8.3 - libarchive 2.8.3
You have /usr/bin/unzip
Searching Plack::Middleware::Session on cpanmetadb ...
--2013-06-24 21:41:35--  http://cpanmetadb.plackperl.org/v1.0/package/Plack::Middleware::Session
Resolving cpanmetadb.plackperl.org... 199.27.77.129, 199.27.77.192
Connecting to cpanmetadb.plackperl.org|199.27.77.129|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 79 [text/x-yaml]
Saving to: ‘STDOUT’

100%[======================================>] 79          --.-K/s   in 0s

2013-06-24 21:41:36 (5.38 MB/s) - written to stdout [79/79]

--> Working on Plack::Middleware::Session
Fetching http://www.cpan.org/authors/id/M/MI/MIYAGAWA/Plack-Middleware-Session-0.18.tar.gz ... --2013-06-24 21:41:36--  http://www.cpan.org/authors/id/M/MI/MIYAGAWA/Plack-Middleware-Session-0.18.tar.gz
Resolving www.cpan.org... 212.117.177.118, 207.171.7.177, 2620:101:d000:8::140:1, ...
Connecting to www.cpan.org|212.117.177.118|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 32912 (32K) [application/x-gzip]
Saving to: ‘Plack-Middleware-Session-0.18.tar.gz’

100%[======================================>] 32,912      9.53KB/s   in 3.4s

2013-06-24 21:41:40 (9.53 KB/s) - ‘Plack-Middleware-Session-0.18.tar.gz’ saved [32912/32912]

OK
Unpacking Plack-Middleware-Session-0.18.tar.gz
x Plack-Middleware-Session-0.18/
x Plack-Middleware-Session-0.18/.shipit
x Plack-Middleware-Session-0.18/Changes
x Plack-Middleware-Session-0.18/cpanfile
x Plack-Middleware-Session-0.18/examples/
x Plack-Middleware-Session-0.18/inc/
x Plack-Middleware-Session-0.18/lib/
x Plack-Middleware-Session-0.18/Makefile.PL
x Plack-Middleware-Session-0.18/MANIFEST
x Plack-Middleware-Session-0.18/META.json
x Plack-Middleware-Session-0.18/META.yml
x Plack-Middleware-Session-0.18/README
x Plack-Middleware-Session-0.18/t/
x Plack-Middleware-Session-0.18/t/000_load.t
x Plack-Middleware-Session-0.18/t/001_basic.t
x Plack-Middleware-Session-0.18/t/001a_basic.t
x Plack-Middleware-Session-0.18/t/002_basic_w_cookie.t
x Plack-Middleware-Session-0.18/t/002a_basic_w_cookie.t
x Plack-Middleware-Session-0.18/t/003_basic_w_file_store.t
x Plack-Middleware-Session-0.18/t/003a_basic_w_file_store.t
x Plack-Middleware-Session-0.18/t/004_basic_file_w_customs.t
x Plack-Middleware-Session-0.18/t/004a_basic_file_w_customs.t
x Plack-Middleware-Session-0.18/t/005_basic_w_cache_store.t
x Plack-Middleware-Session-0.18/t/005a_basic_w_cache_store.t
x Plack-Middleware-Session-0.18/t/006_basic_w_dbi_store.t
x Plack-Middleware-Session-0.18/t/010_middleware.t
x Plack-Middleware-Session-0.18/t/010a_middleware.t
x Plack-Middleware-Session-0.18/t/012_streaming.t
x Plack-Middleware-Session-0.18/t/013_cookiestore.t
x Plack-Middleware-Session-0.18/t/014_cookie_options.t
x Plack-Middleware-Session-0.18/t/015_cookie_options_mw.t
x Plack-Middleware-Session-0.18/t/lib/
x Plack-Middleware-Session-0.18/t/lib/TestSession.pm
x Plack-Middleware-Session-0.18/t/lib/TestSessionHash.pm
x Plack-Middleware-Session-0.18/lib/Plack/
x Plack-Middleware-Session-0.18/lib/Plack/Middleware/
x Plack-Middleware-Session-0.18/lib/Plack/Session/
x Plack-Middleware-Session-0.18/lib/Plack/Session.pm
x Plack-Middleware-Session-0.18/lib/Plack/Session/State/
x Plack-Middleware-Session-0.18/lib/Plack/Session/State.pm
x Plack-Middleware-Session-0.18/lib/Plack/Session/Store/
x Plack-Middleware-Session-0.18/lib/Plack/Session/Store.pm
x Plack-Middleware-Session-0.18/lib/Plack/Session/Store/Cache.pm
x Plack-Middleware-Session-0.18/lib/Plack/Session/Store/DBI.pm
x Plack-Middleware-Session-0.18/lib/Plack/Session/Store/File.pm
x Plack-Middleware-Session-0.18/lib/Plack/Session/Store/Null.pm
x Plack-Middleware-Session-0.18/lib/Plack/Session/State/Cookie.pm
x Plack-Middleware-Session-0.18/lib/Plack/Middleware/Session/
x Plack-Middleware-Session-0.18/lib/Plack/Middleware/Session.pm
x Plack-Middleware-Session-0.18/lib/Plack/Middleware/Session/Cookie.pm
x Plack-Middleware-Session-0.18/inc/Module/
x Plack-Middleware-Session-0.18/inc/Module/Install/
x Plack-Middleware-Session-0.18/inc/Module/Install.pm
x Plack-Middleware-Session-0.18/inc/Module/Install/Base.pm
x Plack-Middleware-Session-0.18/inc/Module/Install/Can.pm
x Plack-Middleware-Session-0.18/inc/Module/Install/Fetch.pm
x Plack-Middleware-Session-0.18/inc/Module/Install/Makefile.pm
x Plack-Middleware-Session-0.18/inc/Module/Install/Metadata.pm
x Plack-Middleware-Session-0.18/inc/Module/Install/Win32.pm
x Plack-Middleware-Session-0.18/inc/Module/Install/WriteAll.pm
x Plack-Middleware-Session-0.18/examples/counter-raw.psgi
Entering Plack-Middleware-Session-0.18
Checking configure dependencies from META.json
Checking if you have CPAN::Meta 0 ... Yes (2.120921)
Checking if you have ExtUtils::MakeMaker 6.36 ... Yes (6.66)
Configuring Plack-Middleware-Session-0.17 ... Running Makefile.PL
Cannot determine perl version info from lib/Plack/Middleware/Session.pm
Checking if your kit is complete...
Looks good
Writing Makefile for Plack::Middleware::Session
Writing MYMETA.yml and MYMETA.json
OK
Checking dependencies from MYMETA.json ...
Checking if you have Test::More 0.88 ... Yes (0.98)
Checking if you have ExtUtils::MakeMaker 6.36 ... Yes (6.66)
Checking if you have Plack 0.9910 ... Yes (1.0028)
Checking if you have Test::Requires 0 ... Yes (0.06)
Checking if you have Digest::SHA1 0 ... Yes (2.13)
Checking if you have Test::Fatal 0.006 ... Yes (0.010)
Checking if you have Digest::HMAC_SHA1 1.03 ... Yes (1.03)
Building and testing Plack-Middleware-Session-0.17 ... cp lib/Plack/Middleware/Session.pm blib/lib/Plack/Middleware/Session.pm
cp lib/Plack/Session/Store/DBI.pm blib/lib/Plack/Session/Store/DBI.pm
cp lib/Plack/Session.pm blib/lib/Plack/Session.pm
cp lib/Plack/Session/Store/Cache.pm blib/lib/Plack/Session/Store/Cache.pm
cp lib/Plack/Session/Store/File.pm blib/lib/Plack/Session/Store/File.pm
cp lib/Plack/Session/Store.pm blib/lib/Plack/Session/Store.pm
cp lib/Plack/Session/State.pm blib/lib/Plack/Session/State.pm
cp lib/Plack/Session/Store/Null.pm blib/lib/Plack/Session/Store/Null.pm
cp lib/Plack/Session/State/Cookie.pm blib/lib/Plack/Session/State/Cookie.pm
cp lib/Plack/Middleware/Session/Cookie.pm blib/lib/Plack/Middleware/Session/Cookie.pm
Manifying blib/man3/Plack::Session::Store::Cache.3
Manifying blib/man3/Plack::Session::Store.3
Manifying blib/man3/Plack::Session::Store::File.3
Manifying blib/man3/Plack::Session::State.3
Manifying blib/man3/Plack::Middleware::Session.3
Manifying blib/man3/Plack::Session::Store::Null.3
Manifying blib/man3/Plack::Session.3
Manifying blib/man3/Plack::Session::State::Cookie.3
Manifying blib/man3/Plack::Session::Store::DBI.3
Manifying blib/man3/Plack::Middleware::Session::Cookie.3
PERL_DL_NONLAZY=1 /Users/skaji/.plenv/versions/c5.18.0/bin/perl5.18.0 "-MExtUtils::Command::MM" "-e" "test_harness(0, 'inc', 'blib/lib', 'blib/arch')" t/*.t
t/000_load.t ................... ok
t/001_basic.t .................. ok
t/001a_basic.t ................. ok
t/002_basic_w_cookie.t ......... ok
t/002a_basic_w_cookie.t ........ ok
t/003_basic_w_file_store.t ..... ok
t/003a_basic_w_file_store.t .... ok
t/004_basic_file_w_customs.t ... skipped: Test requires module 'YAML' but it's not found
t/004a_basic_file_w_customs.t .. skipped: Test requires module 'YAML' but it's not found
t/005_basic_w_cache_store.t .... ok
t/005a_basic_w_cache_store.t ... ok
t/006_basic_w_dbi_store.t ...... skipped: Test requires module 'DBI' but it's not found
t/010_middleware.t ............. Can't locate HTTP/Cookies.pm in @INC (you may need to install the HTTP::Cookies module) (@INC contains: /Users/skaji/.cpanm/work/1372077695.11643/Plack-Middleware-Session-0.18/inc /Users/skaji/.cpanm/work/1372077695.11643/Plack-Middleware-Session-0.18/blib/lib /Users/skaji/.cpanm/work/1372077695.11643/Plack-Middleware-Session-0.18/blib/arch /Users/skaji/.plenv/versions/c5.18.0/lib/perl5/site_perl/5.18.0/darwin-2level /Users/skaji/.plenv/versions/c5.18.0/lib/perl5/site_perl/5.18.0 /Users/skaji/.plenv/versions/c5.18.0/lib/perl5/5.18.0/darwin-2level /Users/skaji/.plenv/versions/c5.18.0/lib/perl5/5.18.0 .) at t/010_middleware.t line 5.
BEGIN failed--compilation aborted at t/010_middleware.t line 5.
t/010_middleware.t ............. Dubious, test returned 2 (wstat 512, 0x200)
No subtests run
t/010a_middleware.t ............ Can't locate HTTP/Cookies.pm in @INC (you may need to install the HTTP::Cookies module) (@INC contains: /Users/skaji/.cpanm/work/1372077695.11643/Plack-Middleware-Session-0.18/inc /Users/skaji/.cpanm/work/1372077695.11643/Plack-Middleware-Session-0.18/blib/lib /Users/skaji/.cpanm/work/1372077695.11643/Plack-Middleware-Session-0.18/blib/arch /Users/skaji/.plenv/versions/c5.18.0/lib/perl5/site_perl/5.18.0/darwin-2level /Users/skaji/.plenv/versions/c5.18.0/lib/perl5/site_perl/5.18.0 /Users/skaji/.plenv/versions/c5.18.0/lib/perl5/5.18.0/darwin-2level /Users/skaji/.plenv/versions/c5.18.0/lib/perl5/5.18.0 .) at t/010a_middleware.t line 5.
BEGIN failed--compilation aborted at t/010a_middleware.t line 5.
t/010a_middleware.t ............ Dubious, test returned 2 (wstat 512, 0x200)
No subtests run
t/012_streaming.t .............. ok
t/013_cookiestore.t ............ Can't locate LWP/UserAgent.pm in @INC (you may need to install the LWP::UserAgent module) (@INC contains: /Users/skaji/.cpanm/work/1372077695.11643/Plack-Middleware-Session-0.18/inc /Users/skaji/.cpanm/work/1372077695.11643/Plack-Middleware-Session-0.18/blib/lib /Users/skaji/.cpanm/work/1372077695.11643/Plack-Middleware-Session-0.18/blib/arch /Users/skaji/.plenv/versions/c5.18.0/lib/perl5/site_perl/5.18.0/darwin-2level /Users/skaji/.plenv/versions/c5.18.0/lib/perl5/site_perl/5.18.0 /Users/skaji/.plenv/versions/c5.18.0/lib/perl5/5.18.0/darwin-2level /Users/skaji/.plenv/versions/c5.18.0/lib/perl5/5.18.0 .) at t/013_cookiestore.t line 7.
BEGIN failed--compilation aborted at t/013_cookiestore.t line 7.
t/013_cookiestore.t ............ Dubious, test returned 2 (wstat 512, 0x200)
No subtests run
t/014_cookie_options.t ......... ok
t/015_cookie_options_mw.t ...... Can't locate HTTP/Cookies.pm in @INC (you may need to install the HTTP::Cookies module) (@INC contains: /Users/skaji/.cpanm/work/1372077695.11643/Plack-Middleware-Session-0.18/inc /Users/skaji/.cpanm/work/1372077695.11643/Plack-Middleware-Session-0.18/blib/lib /Users/skaji/.cpanm/work/1372077695.11643/Plack-Middleware-Session-0.18/blib/arch /Users/skaji/.plenv/versions/c5.18.0/lib/perl5/site_perl/5.18.0/darwin-2level /Users/skaji/.plenv/versions/c5.18.0/lib/perl5/site_perl/5.18.0 /Users/skaji/.plenv/versions/c5.18.0/lib/perl5/5.18.0/darwin-2level /Users/skaji/.plenv/versions/c5.18.0/lib/perl5/5.18.0 .) at t/015_cookie_options_mw.t line 6.
BEGIN failed--compilation aborted at t/015_cookie_options_mw.t line 6.
t/015_cookie_options_mw.t ...... Dubious, test returned 2 (wstat 512, 0x200)
No subtests run

Test Summary Report
-------------------
t/010_middleware.t           (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: No plan found in TAP output
t/010a_middleware.t          (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: No plan found in TAP output
t/013_cookiestore.t          (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: No plan found in TAP output
t/015_cookie_options_mw.t    (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: No plan found in TAP output
Files=18, Tests=332,  2 wallclock secs ( 0.11 usr  0.04 sys +  1.22 cusr  0.15 csys =  1.52 CPU)
Result: FAIL
Failed 4/18 test programs. 0/332 subtests failed.
make: *** [test_dynamic] Error 2
FAIL
! Installing Plack::Middleware::Session failed. See /Users/skaji/.cpanm/work/1372077695.11643/build.log for details. Retry with --force to force install it.

SEE ALSO link broken in Plack::Middleware::Session::Cookie

Hi,

In the "SEE ALSO" section of the package Plack::Middleware::Session::Cookie, the link for "Rack::Session::Cookie" is broken.
Is it a typo?

I couldn't find any distribution by that name in CPAN search.

Best Regards,
Mohammad S Anwar

calculate cookie expires using lifetime

Plack 0.99* dumped CGI::Simple::Cookie in cookie handling, which means you can't say expires => '+3M' etc. to set session cookie lifetime. Let's take a look at Catalyst::Plugin::Session how it deals with that.

Strange failure in t/004a_basic_file_w_customs.t and t/004_basic_file_w_customs.t ( parallelism fail ? )

given these files are named after the other, one might have been copy-pasted and thus share a dir, not sure, haven't looked in to it in detail yet.

Though I find it odd no other cpan testers have reported this specific failure yet, so that's a good indication it might be me.

Relevant Deps Versions:

  • Cookie::Baker 0.03
  • Digest::HMAC_SHA1 1.03
  • Digest::SHA1 2.13
  • Plack 1.0031
  • HTTP::Cookies 6.01
  • LWP::UserAgent 6.06
  • Test::Fatal 0.013
  • Test::More 1.001006
  • Test::Requires 0.08

Run 1:

t/001_basic.t .................. ok
t/000_load.t ................... ok
t/002_basic_w_cookie.t ......... ok
t/001a_basic.t ................. ok
t/002a_basic_w_cookie.t ........ ok
t/003_basic_w_file_store.t ..... ok
t/003a_basic_w_file_store.t .... ok
t/005_basic_w_cache_store.t .... ok

#   Failed test '... got a basic session id'
#   at t/lib/TestSessionHash.pm line 101.
#          got: '3e9ae7647367cf141183c3914858964e239a5b1b'
#     expected: 'f52c5e94692ee1315487f456e89784e0400f881e'

#   Failed test '... got the value for foo back successfully from session'
#   at t/lib/TestSessionHash.pm line 103.
#          got: undef
#     expected: 'bar'
t/005a_basic_w_cache_store.t ... ok

#   Failed test '... got the session dump we expected'
#   at t/lib/TestSessionHash.pm line 112.
#     Structures begin differing at:
#          $got->{bar} = Does not exist
#     $expected->{bar} = 'baz'

#   Failed test '... got a basic session id'
#   at t/lib/TestSessionHash.pm line 133.
#          got: '15d6f9f11ae6a930e2839e35dcc79d662720f6ec'
#     expected: 'f52c5e94692ee1315487f456e89784e0400f881e'

#   Failed test '... got the session dump we expected'
#   at t/lib/TestSessionHash.pm line 141.
#     Structures begin differing at:
#          $got->{bar} = Does not exist
#     $expected->{bar} = 'baz'
t/014_cookie_options.t ......... ok

#   Failed test '... got the bar value back successfully from session'
#   at t/lib/TestSessionHash.pm line 149.
#          got: undef
#     expected: 'baz'
t/release-pod-syntax.t ......... skipped: these tests are for release candidate testing
t/010a_middleware.t ............ ok
t/010_middleware.t ............. ok
# Looks like you failed 6 tests of 37.
t/004a_basic_file_w_customs.t .. 
Dubious, test returned 6 (wstat 1536, 0x600)
Failed 6/37 subtests 

#   Failed test '... got the bar value back successfully from session'
#   at t/lib/TestSession.pm line 146.
#          got: undef
#     expected: 'baz'

#   Failed test '... got a basic session id'
#   at t/lib/TestSession.pm line 173.
#          got: 'a34a9b026a8177d6731f79ad47e7be3ea0ba0fd9'
#     expected: 'a34c17e662a7c996c476c637e65cf8fad6c6e906'

#   Failed test '... got the foo value back successfully from session'
#   at t/lib/TestSession.pm line 175.
#          got: undef
#     expected: 'baz'

#   Failed test '... got the session dump we expected'
#   at t/lib/TestSession.pm line 177.
#     Structures begin differing at:
#          $got->{foo} = Does not exist
#     $expected->{foo} = 'baz'
# Looks like you failed 4 tests of 38.
t/004_basic_file_w_customs.t ... 
Dubious, test returned 4 (wstat 1024, 0x400)
Failed 4/38 subtests 
t/015_cookie_options_mw.t ...... ok
t/012_streaming.t .............. ok
t/013_cookiestore.t ............ ok
t/016_cookiestore_w_customs.t .. ok
t/006_basic_w_dbi_store.t ...... ok

Test Summary Report
-------------------
t/004a_basic_file_w_customs.t (Wstat: 1536 Tests: 37 Failed: 6)
  Failed tests:  13-14, 17, 21, 24-25
  Non-zero exit status: 6
t/004_basic_file_w_customs.t (Wstat: 1024 Tests: 38 Failed: 4)
  Failed tests:  25, 31-33
  Non-zero exit status: 4
Files=20, Tests=504,  3 wallclock secs ( 0.17 usr  0.06 sys +  3.21 cusr  0.88 csys =  4.32 CPU)

Run 2

t/000_load.t ................... ok
t/001_basic.t .................. ok
t/001a_basic.t ................. ok
t/002_basic_w_cookie.t ......... ok
t/003_basic_w_file_store.t ..... ok
t/005a_basic_w_cache_store.t ... ok
t/002a_basic_w_cookie.t ........ ok
t/005_basic_w_cache_store.t .... ok
t/003a_basic_w_file_store.t .... ok

#   Failed test '... got a basic session id'
#   at t/lib/TestSessionHash.pm line 101.
#          got: '4f33ad60a2d886d3cfe863471e6c4c5d632ec262'
#     expected: 'af4433b9c68043cbfb62bb5ec4a508c6dc5d2d47'

#   Failed test '... got the value for foo back successfully from session'
#   at t/lib/TestSessionHash.pm line 103.
#          got: undef
#     expected: 'bar'

#   Failed test '... got the session dump we expected'
#   at t/lib/TestSessionHash.pm line 112.
#     Structures begin differing at:
#          $got->{bar} = Does not exist
#     $expected->{bar} = 'baz'

#   Failed test '... got a basic session id'
#   at t/lib/TestSessionHash.pm line 133.
#          got: '5caa16208507bd8b0d0ed758ff19ab6a5711114e'
#     expected: 'af4433b9c68043cbfb62bb5ec4a508c6dc5d2d47'

#   Failed test '... got the session dump we expected'
#   at t/lib/TestSessionHash.pm line 141.
#     Structures begin differing at:
#          $got->{bar} = Does not exist
#     $expected->{bar} = 'baz'

#   Failed test '... got the bar value back successfully from session'
#   at t/lib/TestSessionHash.pm line 149.
#          got: undef
#     expected: 'baz'
t/010_middleware.t ............. ok
# Looks like you failed 6 tests of 37.
t/004a_basic_file_w_customs.t .. 
Dubious, test returned 6 (wstat 1536, 0x600)
Failed 6/37 subtests 

#   Failed test '... got a basic session id'
#   at t/lib/TestSession.pm line 118.
#          got: '06d915c5ba41e249af4987dee0eb1baf954a1898'
#     expected: '62cef35da69910492a646be3bcbe974cfe0fc92d'

#   Failed test '... got the foo value back successfully from session'
#   at t/lib/TestSession.pm line 120.
#          got: undef
#     expected: 'baz'

#   Failed test '... got the session dump we expected'
#   at t/lib/TestSession.pm line 122.
#     Structures begin differing at:
#          $got->{foo} = Does not exist
#     $expected->{foo} = 'baz'

#   Failed test '... got a basic session id'
#   at t/lib/TestSession.pm line 173.
#          got: 'd889a72393a6dc7cdb03a15e4067b9eaa3d06032'
#     expected: '62cef35da69910492a646be3bcbe974cfe0fc92d'

#   Failed test '... got the foo value back successfully from session'
#   at t/lib/TestSession.pm line 175.
#          got: undef
#     expected: 'baz'

#   Failed test '... got the session dump we expected'
#   at t/lib/TestSession.pm line 177.
#     Structures begin differing at:
#          $got->{foo} = Does not exist
#     $expected->{foo} = 'baz'
# Looks like you failed 6 tests of 38.
t/004_basic_file_w_customs.t ... 
Dubious, test returned 6 (wstat 1536, 0x600)
Failed 6/38 subtests 
t/014_cookie_options.t ......... ok
t/010a_middleware.t ............ ok
t/release-pod-syntax.t ......... skipped: these tests are for release candidate testing
t/015_cookie_options_mw.t ...... ok
t/012_streaming.t .............. ok
t/013_cookiestore.t ............ ok
t/016_cookiestore_w_customs.t .. ok
t/006_basic_w_dbi_store.t ...... ok

Test Summary Report
-------------------
t/004a_basic_file_w_customs.t (Wstat: 1536 Tests: 37 Failed: 6)
  Failed tests:  13-14, 17, 21, 24-25
  Non-zero exit status: 6
t/004_basic_file_w_customs.t (Wstat: 1536 Tests: 38 Failed: 6)
  Failed tests:  18-20, 31-33
  Non-zero exit status: 6
Files=20, Tests=504,  4 wallclock secs ( 0.17 usr  0.06 sys +  3.22 cusr  0.86 csys =  4.31 CPU)
Result: FAIL

Plack-Middleware-Session: tests fail on Perl 5 blead: no dot in default @INC

In Perl 5.26.0, . will no longer be found by default in @INC. Programs which use a module located underneath . must add that directory manually to @INC.

Today I attempted to configure, build and test this library with Perl 5 blead and an up-to-date cpanm. These were my results:

[Plack-Middleware-Session] 652 $ !622
/home/jkeenan/testing/blead/bin/perl -I /home/jkeenan/testing/blead/lib Build.PL
Creating new 'Build' script for 'Plack-Middleware-Session' version '0.30'
[Plack-Middleware-Session] 653 $ ./Build
cp lib/Plack/Middleware/Session/Cookie.pm blib/lib/Plack/Middleware/Session/Cookie.pm
cp lib/Plack/Session/Store/DBI.pm blib/lib/Plack/Session/Store/DBI.pm
cp lib/Plack/Session/Store/Cache.pm blib/lib/Plack/Session/Store/Cache.pm
cp lib/Plack/Session/Store/Null.pm blib/lib/Plack/Session/Store/Null.pm
cp lib/Plack/Session/State/Cookie.pm blib/lib/Plack/Session/State/Cookie.pm
cp lib/Plack/Session.pm blib/lib/Plack/Session.pm
cp lib/Plack/Middleware/Session.pm blib/lib/Plack/Middleware/Session.pm
cp lib/Plack/Session/Store/File.pm blib/lib/Plack/Session/Store/File.pm
cp lib/Plack/Session/Store.pm blib/lib/Plack/Session/Store.pm
cp lib/Plack/Session/Cleanup.pm blib/lib/Plack/Session/Cleanup.pm
cp lib/Plack/Session/State.pm blib/lib/Plack/Session/State.pm
[Plack-Middleware-Session] 654 $ ./Build test
t/000_load.t ................... ok   
t/001_basic.t .................. Can't locate t/lib/TestSession.pm in @INC (you may need to install the t::lib::TestSession module) (@INC contains: /home/jkeenan/gitwork/zzzothers/Plack-Middleware-Session/blib/arch /home/jkeenan/gitwork/zzzothers/Plack-Middleware-Session/blib/lib /home/jkeenan/testing/blead/lib/perl5/site_perl/5.26.0/x86_64-linux /home/jkeenan/testing/blead/lib/perl5/site_perl/5.26.0 /home/jkeenan/testing/blead/lib/perl5/5.26.0/x86_64-linux /home/jkeenan/testing/blead/lib/perl5/5.26.0) at t/001_basic.t line 13.
BEGIN failed--compilation aborted at t/001_basic.t line 13.
t/001_basic.t .................. Dubious, test returned 2 (wstat 512, 0x200)
No subtests run 
t/001a_basic.t ................. Can't locate t/lib/TestSessionHash.pm in @INC (you may need to install the t::lib::TestSessionHash module) (@INC contains: /home/jkeenan/gitwork/zzzothers/Plack-Middleware-Session/blib/arch /home/jkeenan/gitwork/zzzothers/Plack-Middleware-Session/blib/lib /home/jkeenan/testing/blead/lib/perl5/site_perl/5.26.0/x86_64-linux /home/jkeenan/testing/blead/lib/perl5/site_perl/5.26.0 /home/jkeenan/testing/blead/lib/perl5/5.26.0/x86_64-linux /home/jkeenan/testing/blead/lib/perl5/5.26.0) at t/001a_basic.t line 12.
BEGIN failed--compilation aborted at t/001a_basic.t line 12.
t/001a_basic.t ................. Dubious, test returned 2 (wstat 512, 0x200)
No subtests run 
t/002_basic_w_cookie.t ......... Can't locate t/lib/TestSession.pm in @INC (you may need to install the t::lib::TestSession module) (@INC contains: /home/jkeenan/gitwork/zzzothers/Plack-Middleware-Session/blib/arch /home/jkeenan/gitwork/zzzothers/Plack-Middleware-Session/blib/lib /home/jkeenan/testing/blead/lib/perl5/site_perl/5.26.0/x86_64-linux /home/jkeenan/testing/blead/lib/perl5/site_perl/5.26.0 /home/jkeenan/testing/blead/lib/perl5/5.26.0/x86_64-linux /home/jkeenan/testing/blead/lib/perl5/5.26.0) at t/002_basic_w_cookie.t line 14.
BEGIN failed--compilation aborted at t/002_basic_w_cookie.t line 14.
t/002_basic_w_cookie.t ......... Dubious, test returned 2 (wstat 512, 0x200)
No subtests run 
t/002a_basic_w_cookie.t ........ Can't locate t/lib/TestSessionHash.pm in @INC (you may need to install the t::lib::TestSessionHash module) (@INC contains: /home/jkeenan/gitwork/zzzothers/Plack-Middleware-Session/blib/arch /home/jkeenan/gitwork/zzzothers/Plack-Middleware-Session/blib/lib /home/jkeenan/testing/blead/lib/perl5/site_perl/5.26.0/x86_64-linux /home/jkeenan/testing/blead/lib/perl5/site_perl/5.26.0 /home/jkeenan/testing/blead/lib/perl5/5.26.0/x86_64-linux /home/jkeenan/testing/blead/lib/perl5/5.26.0) at t/002a_basic_w_cookie.t line 13.
BEGIN failed--compilation aborted at t/002a_basic_w_cookie.t line 13.
t/002a_basic_w_cookie.t ........ Dubious, test returned 2 (wstat 512, 0x200)
No subtests run 
t/003_basic_w_file_store.t ..... Can't locate t/lib/TestSession.pm in @INC (you may need to install the t::lib::TestSession module) (@INC contains: /home/jkeenan/gitwork/zzzothers/Plack-Middleware-Session/blib/arch /home/jkeenan/gitwork/zzzothers/Plack-Middleware-Session/blib/lib /home/jkeenan/testing/blead/lib/perl5/site_perl/5.26.0/x86_64-linux /home/jkeenan/testing/blead/lib/perl5/site_perl/5.26.0 /home/jkeenan/testing/blead/lib/perl5/5.26.0/x86_64-linux /home/jkeenan/testing/blead/lib/perl5/5.26.0) at t/003_basic_w_file_store.t line 15.
BEGIN failed--compilation aborted at t/003_basic_w_file_store.t line 15.
t/003_basic_w_file_store.t ..... Dubious, test returned 2 (wstat 512, 0x200)
No subtests run 
t/003a_basic_w_file_store.t .... Can't locate t/lib/TestSessionHash.pm in @INC (you may need to install the t::lib::TestSessionHash module) (@INC contains: /home/jkeenan/gitwork/zzzothers/Plack-Middleware-Session/blib/arch /home/jkeenan/gitwork/zzzothers/Plack-Middleware-Session/blib/lib /home/jkeenan/testing/blead/lib/perl5/site_perl/5.26.0/x86_64-linux /home/jkeenan/testing/blead/lib/perl5/site_perl/5.26.0 /home/jkeenan/testing/blead/lib/perl5/5.26.0/x86_64-linux /home/jkeenan/testing/blead/lib/perl5/5.26.0) at t/003a_basic_w_file_store.t line 14.
BEGIN failed--compilation aborted at t/003a_basic_w_file_store.t line 14.
t/003a_basic_w_file_store.t .... Dubious, test returned 2 (wstat 512, 0x200)
No subtests run 
t/004_basic_file_w_customs.t ... Can't locate t/lib/TestSession.pm in @INC (you may need to install the t::lib::TestSession module) (@INC contains: /home/jkeenan/gitwork/zzzothers/Plack-Middleware-Session/blib/arch /home/jkeenan/gitwork/zzzothers/Plack-Middleware-Session/blib/lib /home/jkeenan/testing/blead/lib/perl5/site_perl/5.26.0/x86_64-linux /home/jkeenan/testing/blead/lib/perl5/site_perl/5.26.0 /home/jkeenan/testing/blead/lib/perl5/5.26.0/x86_64-linux /home/jkeenan/testing/blead/lib/perl5/5.26.0) at t/004_basic_file_w_customs.t line 16.
BEGIN failed--compilation aborted at t/004_basic_file_w_customs.t line 16.
t/004_basic_file_w_customs.t ... Dubious, test returned 2 (wstat 512, 0x200)
No subtests run 
t/004a_basic_file_w_customs.t .. Can't locate t/lib/TestSessionHash.pm in @INC (you may need to install the t::lib::TestSessionHash module) (@INC contains: /home/jkeenan/gitwork/zzzothers/Plack-Middleware-Session/blib/arch /home/jkeenan/gitwork/zzzothers/Plack-Middleware-Session/blib/lib /home/jkeenan/testing/blead/lib/perl5/site_perl/5.26.0/x86_64-linux /home/jkeenan/testing/blead/lib/perl5/site_perl/5.26.0 /home/jkeenan/testing/blead/lib/perl5/5.26.0/x86_64-linux /home/jkeenan/testing/blead/lib/perl5/5.26.0) at t/004a_basic_file_w_customs.t line 15.
BEGIN failed--compilation aborted at t/004a_basic_file_w_customs.t line 15.
t/004a_basic_file_w_customs.t .. Dubious, test returned 2 (wstat 512, 0x200)
No subtests run 
t/005_basic_w_cache_store.t .... Can't locate t/lib/TestSession.pm in @INC (you may need to install the t::lib::TestSession module) (@INC contains: /home/jkeenan/gitwork/zzzothers/Plack-Middleware-Session/blib/arch /home/jkeenan/gitwork/zzzothers/Plack-Middleware-Session/blib/lib /home/jkeenan/testing/blead/lib/perl5/site_perl/5.26.0/x86_64-linux /home/jkeenan/testing/blead/lib/perl5/site_perl/5.26.0 /home/jkeenan/testing/blead/lib/perl5/5.26.0/x86_64-linux /home/jkeenan/testing/blead/lib/perl5/5.26.0) at t/005_basic_w_cache_store.t line 13.
BEGIN failed--compilation aborted at t/005_basic_w_cache_store.t line 13.
t/005_basic_w_cache_store.t .... Dubious, test returned 2 (wstat 512, 0x200)
No subtests run 
t/005a_basic_w_cache_store.t ... Can't locate t/lib/TestSessionHash.pm in @INC (you may need to install the t::lib::TestSessionHash module) (@INC contains: /home/jkeenan/gitwork/zzzothers/Plack-Middleware-Session/blib/arch /home/jkeenan/gitwork/zzzothers/Plack-Middleware-Session/blib/lib /home/jkeenan/testing/blead/lib/perl5/site_perl/5.26.0/x86_64-linux /home/jkeenan/testing/blead/lib/perl5/site_perl/5.26.0 /home/jkeenan/testing/blead/lib/perl5/5.26.0/x86_64-linux /home/jkeenan/testing/blead/lib/perl5/5.26.0) at t/005a_basic_w_cache_store.t line 12.
BEGIN failed--compilation aborted at t/005a_basic_w_cache_store.t line 12.
t/005a_basic_w_cache_store.t ... Dubious, test returned 2 (wstat 512, 0x200)
No subtests run 
t/006_basic_w_dbi_store.t ...... Can't locate t/lib/TestSession.pm in @INC (you may need to install the t::lib::TestSession module) (@INC contains: /home/jkeenan/gitwork/zzzothers/Plack-Middleware-Session/blib/arch /home/jkeenan/gitwork/zzzothers/Plack-Middleware-Session/blib/lib /home/jkeenan/testing/blead/lib/perl5/site_perl/5.26.0/x86_64-linux /home/jkeenan/testing/blead/lib/perl5/site_perl/5.26.0 /home/jkeenan/testing/blead/lib/perl5/5.26.0/x86_64-linux /home/jkeenan/testing/blead/lib/perl5/5.26.0) at t/006_basic_w_dbi_store.t line 16.
BEGIN failed--compilation aborted at t/006_basic_w_dbi_store.t line 16.
t/006_basic_w_dbi_store.t ...... Dubious, test returned 2 (wstat 512, 0x200)
No subtests run 
t/010_middleware.t ............. ok   
t/010a_middleware.t ............ ok   
t/012_streaming.t .............. ok    
t/013_cookiestore.t ............ ok   
t/014_cookie_options.t ......... ok   
t/015_cookie_options_mw.t ...... ok   
t/016_cookiestore_w_customs.t .. ok   

Test Summary Report
-------------------
t/001_basic.t                (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: No plan found in TAP output
t/001a_basic.t               (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: No plan found in TAP output
t/002_basic_w_cookie.t       (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: No plan found in TAP output
t/002a_basic_w_cookie.t      (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: No plan found in TAP output
t/003_basic_w_file_store.t   (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: No plan found in TAP output
t/003a_basic_w_file_store.t  (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: No plan found in TAP output
t/004_basic_file_w_customs.t (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: No plan found in TAP output
t/004a_basic_file_w_customs.t (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: No plan found in TAP output
t/005_basic_w_cache_store.t  (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: No plan found in TAP output
t/005a_basic_w_cache_store.t (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: No plan found in TAP output
t/006_basic_w_dbi_store.t    (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: No plan found in TAP output
Files=19, Tests=42,  2 wallclock secs ( 0.05 usr  0.01 sys +  1.45 cusr  0.18 csys =  1.69 CPU)
Result: FAIL

I will attempt to provide a pull request.

inconsistent version

Plack-Middleware-Session-0.29 has Plack::Session 0.23.
Plack-Middleware-Session-0.24 has Plack::Session 0.24.

Thus if I install Plack::Session, Plack::Middleware::Session is downgraded:

$ perl -MPlack::Middleware::Session -le 'print Plack::Middleware::Session->VERSION'
0.29

$ cpanm Plack::Session
--> Working on Plack::Session
Fetching http://www.cpan.org/authors/id/M/MI/MIYAGAWA/Plack-Middleware-Session-0.24.tar.gz ... OK
Configuring Plack-Middleware-Session-0.24 ... OK
Building and testing Plack-Middleware-Session-0.24 ... OK
Successfully installed Plack-Middleware-Session-0.24 (upgraded from 0.23)
1 distribution installed

$ perl -MPlack::Middleware::Session -le 'print Plack::Middleware::Session->VERSION'
0.24

I don't think this is intended, so It's nice to bump up versions of all modules in the next release.

Storable deserealization fail should cause 500

If you move your code from old server with 32bit arch and old Storable to a new one, and an old client comes in with old cookie it'll cause Storable::thaw to die on that data. Aint good behavior for a site to throw out 500 like this.

Here is the quick patch i propose at the line 24:

package Plack::Middleware::Session::Cookie;
...
    $self->deserializer(sub {
        my $result;
        eval {
            $result = Storable::thaw(MIME::Base64::decode($_[0]))
        };
        return if $@;
        return $result;
    }) unless $self->deserializer;

updated Plack/Middleware/Session/Cookie.pm attribute list to make SameSite=Lax appear

First -- your software is awesome. Thank you.

I also apologize if this resulted from my misunderstanding. But to make SameSite=Lax appear in Set-Cookie, I updated lib/Plack/Middleware/Session/Cookie.pm like this:

5c5
< use Plack::Util::Accessor qw(secret session_key domain expires path secure httponly samesite
---
> use Plack::Util::Accessor qw(secret session_key domain expires path secure httponly
31c31
<     for my $attr (qw(session_key path domain expires secure httponly samesite)) {
---
>     for my $attr (qw(session_key path domain expires secure httponly)) {
144c144
< =item session_key, domain, expires, path, secure, httponly, samesite
---
> =item session_key, domain, expires, path, secure, httponly

Background:

For security reasons our cookies must contain both SameSite and HttpOnly. I updated our .psgi like this:

    enable 'Session::Cookie',
      store    => 'File',
      secret   => 'top-secret',
      httponly => 1,              # security
      samesite => 'Lax',          # requires bugfix
      ;

However, only HttpOnly appeared in Set-Cookie:

Set-Cookie: plack_session=1679947687.28941%3ABQoDAAAAAQoUZDVhODVmMjNhMTQyMGU5Yzg0NDMAAAAKY3NyZl90b2tlbg%3D%3D%3Aed3d2d7ca08f109168b356aae8334d04b9619ffc; path=/; HttpOnly

I could not make the SameSite entry appear. I tried many permutations.

When I inspected Plack::Session::State::Cookie I realized that samesite was not listed alongside httponly. I addedsamesite everywhere, and voila, the flag immediately appeared!

Set-Cookie: plack_session=1679948062.33454%3ABQgDAAAAAQoUMzQ3MTU0NWUyZWZmNjUyYWJlZTIAAAAKY3NyZl90b2tlbg%3D%3D%3A2a82445e6fe462efebcf4b429b357bc279f5eb1b; path=/; SameSite=Lax; HttpOnly

Once again, I apologize if I misunderstood something here.

Have a great day, and thanks again for some amazing modules.

Build.PL failure

Hi,

As a part of CPAN Pull Request Challenge, I have been looking at the distribution "Plack-Middleware-Session" closely. In my research, I noticed if I try to install the distribution using Build.PL script, I get dependency error thrown as below:

  manwar@ubuntu:~/my-github/plack-middleware-session$ perl Build.PL
  Creating new 'Build' script for 'Plack-Middleware-Session' version '0.25'

  manwar@ubuntu:~/my-github/plack-middleware-session$ ./Build 
  cp lib/Plack/Session.pm blib/lib/Plack/Session.pm
  cp lib/Plack/Session/State.pm blib/lib/Plack/Session/State.pm
  cp lib/Plack/Session/Store.pm blib/lib/Plack/Session/Store.pm
  cp lib/Plack/Session/Store/File.pm blib/lib/Plack/Session/Store/File.pm
  cp lib/Plack/Middleware/Session.pm blib/lib/Plack/Middleware/Session.pm
  cp lib/Plack/Session/Store/DBI.pm blib/lib/Plack/Session/Store/DBI.pm
  cp lib/Plack/Session/Store/Null.pm blib/lib/Plack/Session/Store/Null.pm
  cp lib/Plack/Middleware/Session/Cookie.pm blib/lib/Plack/Middleware/Session/Cookie.pm
  cp lib/Plack/Session/State/Cookie.pm blib/lib/Plack/Session/State/Cookie.pm
  cp lib/Plack/Session/Store/Cache.pm blib/lib/Plack/Session/Store/Cache.pm

  manwar@ubuntu:~/my-github/plack-middleware-session$ ./Build test
  t/000_load.t ................... 1/? 
  #   Failed test 'use Plack::Middleware::Session;'
  #   at t/000_load.t line 8.
  #     Tried to use 'Plack::Middleware::Session'.
  #     Error:  Can't locate Plack/Util.pm in @INC (@INC contains: /home/manwar/my-github/plack-    
  middleware-session/blib/arch /home/manwar/my-github/plack-middleware-session/blib/lib  
  /etc/perl /usr/local/lib/perl/5.10.1 /usr/local/share/perl/5.10.1 /usr/lib/perl5 /usr/share/perl5      
  /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at /home/manwar/my-github/plack-  
  middleware-session/blib/lib/Plack/Middleware/Session.pm line 8.
  # BEGIN failed--compilation aborted at /home/manwar/my-github/plack-middleware-   
  session/blib/lib/Plack/Middleware/Session.pm line 8.
  # Compilation failed in require at t/000_load.t line 8.
  # BEGIN failed--compilation aborted at t/000_load.t line 8.
  Use of uninitialized value $reason in concatenation (.) or string at  
  /usr/local/share/perl/5.10.1/Test/Builder.pm line 1272.
  Bailout called.  Further testing stopped:  
  # Tests were run but no plan was declared and done_testing() was not seen.
  # Looks like your test exited with 255 just after 1.
  FAILED--Further testing stopped.

It could be the Build.PL, part of the distribtion and generated by Dist::Zilla::Plugin::ModuleBuildTiny 0.007, seems to be broken.

I must admit here that I am not familiar with the new way of build/install CPAN modules. I still use the traditional Makefile.PL/Build.PL file to install the distribution.

If I use the command "sudo cpanm ." to install the distribution, it works like a charm.

Am I not using the Build.PL script correctly?

If you agree then I can create a traditional Build.PL by hand, with details of all pre-requisites and all other meta information.

Best Regards,
Mohammad S Anwar

Session object is not created when using with CGI::Application

Hello dear Plack Team,

Thank you very much for your great work. I tried to use Plack::Middleware::Session with a simple CGI::Application app but I had to create the Plack::Session object in my Application module manually.

I thought - after reading the docs of Plack::Session - this should work:
My instance script:

    my $app = sub {
        my $env = shift;
        my $webapp = AppModule->new( QUERY => CGI::PSGI->new($env),  
    [bla bla bla]
    'env' => $env
    }
);
$webapp->run_as_psgi();
    };
    builder {
    enable 'Session';
    $app;
    };

My Application Module:

    sub cgiapp_prerun {
    my $self = shift;
    my $current_runmode = shift;
    # initialize the session
    my $q =$self->query;
    my $env = $q->env;
    my $session = $env->{'psgix.session'};
    # Check the Login Status and if the user is logged in, start the chosen action
    my $login = $session->get('login');
    unless ($login) {
	$self->prerun_mode('show_login') if ($current_runmode ne 'login_cb');
        }
    }

But unfortunately I got the following error:

Error executing class callback in prerun stage: Can't call method "get" on unblessed reference at /home/maximilian/public_html/cgi-bin/./lib/PLogPSGI.pm line 63. at /home/maximilian/public_html/cgi-bin/extlib/lib/perl5/CGI/Application.pm line 2449

We solved it at the CGI App list with manually creating the session object in cgiapp_prerun as follows:
my $session = Plack::Session->new($env);

I don't know why the usual way for Plack::Middleware::Session doesn't work. Perhaps you have an idea? It would be great if Plack::Middleware::Session could also under CGI::Application work as usual.

In advance thank you very very much for everything, your invaluable work and your generous help,
Max

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.