Bug 30348 - Create sub clear_session_and_cookies
Summary: Create sub clear_session_and_cookies
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Authentication (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on: 28786 29957
Blocks:
  Show dependency treegraph
 
Reported: 2022-03-24 10:41 UTC by Marcel de Rooy
Modified: 2023-06-19 00:07 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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?