--- loncom/auth/lonlogout.pm 2007/08/25 00:51:24 1.27 +++ loncom/auth/lonlogout.pm 2007/10/02 01:09:59 1.29 @@ -1,7 +1,7 @@ # The LearningOnline Network # Logout Handler # -# $Id: lonlogout.pm,v 1.27 2007/08/25 00:51:24 albertel Exp $ +# $Id: lonlogout.pm,v 1.29 2007/10/02 01:09:59 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -41,23 +41,16 @@ sub handler { #Check for cookie my $requrl=$r->uri; - my %cookies=CGI::Cookie->parse($r->header_in('Cookie')); - my $lonid=$cookies{'lonID'}; - my $cookie; - if (!$lonid) { - return FORBIDDEN; - } - + my $handle = &Apache::lonnet::check_for_valid_session($r); #check if cookie still valid - my $handle=&LONCAPA::clean_handle($lonid->value); - my $lonidsdir=$r->dir_config('lonIDsDir'); - if ((!-e "$lonidsdir/$handle.id") || ($handle eq '')) { + if ($handle eq '') { $r->log_reason("Cookie $handle not valid", $r->filename); return FORBIDDEN; } #we've got a valid user my @profile; + my $lonidsdir=$r->dir_config('lonIDsDir'); &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle); unlink("$lonidsdir/$handle.id"); my %temp=('logout' => time); @@ -139,10 +132,15 @@ $windowinfo $relogmessage $end_page ENDDOCUMENT - &Apache::lonnet::flushcourselogs(); + $r->register_cleanup(\&flush_course_logs); return OK; } +sub flush_course_logs { + &Apache::lonnet::flushcourselogs(); + return OK; +} + 1; __END__