Bug 30348

Summary: Create sub clear_session_and_cookies
Product: Koha Reporter: Marcel de Rooy <m.de.rooy>
Component: AuthenticationAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: dcook, dpavlin, jonathan.druart
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 28786, 29957    
Bug Blocks:    

Description Marcel de Rooy 2022-03-24 10:41:50 UTC
Possible follow-up of 29957

Something like:

=head2 clear_session_and_cookies

    ( $session, $sessionID, $cookie ) = clear_session_and_cookies( $session, $sessionID, $cookie, $mgr, $cgi );

=cut

sub clear_session_and_cookies {
    my ( $session, $sessionID, $cookie, $mgr, $cgi ) = @_;
    $mgr //= Koha::CookieManager->new;

    $session->delete;
    $session->flush;
    my @list = ref($cgi) eq 'CGI' ? $cgi->cookie : ();
    push @list, @$cookie if ref($cookie) eq 'ARRAY';
    $cookie = $cookie_mgr->clear_unless( @list );
    C4::Context::_unset_userenv($sessionID);

    return ( undef, undef, $cookie );
}
Comment 1 Jonathan Druart 2022-03-24 10:58:37 UTC
on top of bug 28786 maybe?