How can I not send cookies when I use the Cache-Control header in Catalyst?

I use sessions in my Catalyst application through Session, Session::Store::DBICand Session::State::Cookie.

I have several controllers and methods that send data with a header Cache-Control: public, so it is important that the header Set-Cookie:does not come out with these answers (otherwise it will be cached and sent to other clients, which leads to possible security problems). I have not found a good way to accomplish this.

How can I say Sessionor Session::State::Cookienot to send a cookie in response to a given request?

+3
source share
2

RTFS, Session.pm Catalyst finalize_headers cookie :

finalize_header
⇒ _save_session_expiressession_expires
⇒ _extended_session_expiresextend_session_id (…::Session::State::Cookie)update_session_cookie (…::Session::State::Cookie)

, - . - Cookie.pm, cookie_is_rejecting, cookie .

, , - update_session_cookie cookie_is_rejecting. , cookie_is_rejecting.

, . , klugy, ...

package Catalyst::Plugin::Session::State::Cookie::Sanity;
use base qw/Catalyst::Plugin::Session::State::Cookie/;

use MRO::Compat;

use strict;

sub cookie_is_rejecting {
    my ($c, $cookie) = @_;

    ($c->stash->{cache_control_time} // 0) > 0
        or $c->maybe::next::method( $c, $cookie );
}

1;
+1

, , , , .

, State Cookie cookie :

$c->response->cookies

, - , . , cookie . $c->response->cookies , .

JayK

0

Source: https://habr.com/ru/post/1713448/


All Articles