@@ -, +, @@ --- C4/Auth.pm | 6 ++++-- t/db_dependent/Auth.t | 9 ++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) --- a/C4/Auth.pm +++ a/C4/Auth.pm @@ -958,7 +958,9 @@ sub checkauth { unless ( $userid ) { #we initiate a session prior to checking for a username to allow for anonymous sessions... - $session ||= get_session("") or die "Auth ERROR: Cannot get_session()"; + if( !$session or !$sessionID ) { # if we cleared sessionID, we need a new session + $session = get_session() or die "Auth ERROR: Cannot get_session()"; + } # Save anonymous search history in new session so it can be retrieved # by get_template_and_user to store it in user's search history after @@ -1793,7 +1795,7 @@ sub get_session { $session = CGI::Session->load( $params->{dsn}, $sessionID, $params->{dsn_args} ); } else { $session = CGI::Session->new( $params->{dsn}, $sessionID, $params->{dsn_args} ); - # $session->flush; + # no need to flush here } return $session; } --- a/t/db_dependent/Auth.t +++ a/t/db_dependent/Auth.t @@ -547,7 +547,14 @@ subtest 'checkauth & check_cookie_auth' => sub { # Logging out! $cgi->param('logout.x', 1); - ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth($cgi, 0, {catalogue => 1}); + $cgi->delete( 'userid', 'password' ); + { + local *STDOUT; + my $stdout; + open STDOUT, '>', \$stdout; + ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth($cgi, 0, {catalogue => 1}); + close STDOUT; + } is( $sessionID, undef ); is( $ENV{"HTTP_COOKIE"}, "CGISESSID=$first_sessionID", 'HTTP_COOKIE not unset' ); ( $auth_status, $session) = C4::Auth::check_cookie_auth( $first_sessionID, {catalogue => 1} ); --