PerlDancer / Dancer

The easiest way to write web applications with Perl (Perl web micro-framework)
http://perldancer.org/
738 stars 209 forks source link

Dancer::Session - option to disable send of cookie on session read #987

Open lecar-red opened 10 years ago

lecar-red commented 10 years ago

Need an option to disable sending of a cookie on session read, this would need to be added to both get and get_current_session.

This is causing module Dancer::Debug & Plack debug handler to throw error:

Too late to set another cookie, headers already built

yanick commented 10 years ago

988 merged. Thanks!

neptunix commented 10 years ago

Looks like #988 does not help. Sessions are still being sent to client in cookie Here is my code:

hook 'before' => sub {
    if(request->path_info =~ m{^/api}) {
        info "1 " . Dumper (Dancer::Cookies->cookies->{'today.session'});
        my $session = Dancer::Session->get_current_session(no_update => 1);
        info "2 " . Dumper (Dancer::Cookies->cookies->{'today.session'});
        return;
    }
    ...
}
[16397]  info @0.000381 05/Mar/2014 16:18:06> Starting service at Wed Mar  5 12:18:06 2014 [/home/ubuntu/today/dancer/bin/app.pl:8]
[16398]  info @0.003599 05/Mar/2014 16:18:18> 1 $VAR1 = undef; [/home/ubuntu/today/dancer/lib/Today.pm:30]
[16398]  info @0.018654 05/Mar/2014 16:18:18> 2 $VAR1 = bless( {
                 'domain' => undef,
                 'value' => [
                              '283045786842224453082967775958133537'
                            ],
                 'name' => 'today.session',
                 'secure' => undef,
                 'path' => '/',
                 'http_only' => 1,
                 'expires' => 'Thu, 05-Mar-2015 12:18:18 GMT'
               }, 'Dancer::Cookie' ); [/home/ubuntu/today/dancer/lib/Today.pm:32]

Dancer-1.3120

lecar-red commented 10 years ago

neptunix: you'll need to upgrade to version: 1.3121

see: https://metacpan.org/changes/distribution/Dancer