--- loncom/auth/migrateuser.pm 2018/07/01 00:03:42 1.33 +++ loncom/auth/migrateuser.pm 2018/07/04 16:58:19 1.34 @@ -1,7 +1,7 @@ # The LearningOnline Network # Starts a user off based of an existing token. # -# $Id: migrateuser.pm,v 1.33 2018/07/01 00:03:42 raeburn Exp $ +# $Id: migrateuser.pm,v 1.34 2018/07/04 16:58:19 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -258,12 +258,12 @@ sub ip_changed { sub logout { my ($r,$handle,$data,$lti_env) = @_; - unlink($handle); - if ($env{'user.linkedenv'} ne '') { - my $lonidsdir=$r->dir_config('lonIDsDir'); - if ((-l $env{'user.linkedenv'}) && - (readlink($env{'user.linkedenv'}) eq "$lonidsdir/$handle.id")) { - unlink($env{'user.linkedenv'}); + my $lonidsdir=$r->dir_config('lonIDsDir'); + if (unlink("$lonidsdir/$handle.id")) { + if (($env{'user.linkedenv'} =~ /^[a-f0-9]+_linked$/) && + (-l "$lonidsdir/$env{'user.linkedenv'}.id") && + (readlink("$lonidsdir/$env{'user.linkedenv'}.id") eq "$lonidsdir/$handle.id")) { + unlink("$lonidsdir/$env{'user.linkedenv'}.id"); } } my %temp=('logout' => time); @@ -275,18 +275,15 @@ sub logout { &Apache::loncommon::content_type($r,'text/html'); - #expire the cookie - my $c = new CGI::Cookie(-name => 'lonID', - -value => '', - -expires => '-10y',); - $r->headers_out->add('Set-cookie' => $c); - if ($env{'user.linkedenv'}) { - my $linked = new CGI::Cookie(-name => 'lonLinkID', - -value => '', - -expires => '-10y',); - $r->headers_out->add('Set-cookie' => $linked); + #expire the cookies + my %cookies=CGI::Cookie->parse($r->header_in('Cookie')); + foreach my $name (keys(%cookies)) { + next unless ($name =~ /^lon(|S|Link|Pub)ID$/); + my $c = new CGI::Cookie(-name => $name, + -value => '', + -expires => '-10y',); + $r->headers_out->add('Set-cookie' => $c); } - my $lonhost = $r->dir_config('lonHostID'); my (%info,%user_info,%lti_info); if (ref($lti_env) eq 'HASH') { %lti_info = %{$lti_env};