--- loncom/interface/loncommon.pm 2017/08/14 17:47:15 1.1294 +++ loncom/interface/loncommon.pm 2017/09/28 19:04:37 1.1295 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1294 2017/08/14 17:47:15 raeburn Exp $ +# $Id: loncommon.pm,v 1.1295 2017/09/28 19:04:37 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -16152,7 +16152,23 @@ sub init_user_environment { opendir(DIR,$lonids); while ($filename=readdir(DIR)) { if ($filename=~/^$username\_\d+\_$domain\_$authhost\.id$/) { - unlink($lonids.'/'.$filename); + if ($ENV{'SERVER_PORT'} == 443) { + my $linkedfile; + if (tie(my %oldenv,'GDBM_File',"$lonids/$cookie.id", + &GDBM_READER(),0640)) { + if (exists($oldenv{'user.linkedenv'})) { + $linkedfile = $oldenv{'user.linkedenv'}; + } + untie(%oldenv); + } + if (unlink($lonids.'/'.$filename)) { + if ($linkedfile =~ /^[a-f0-9]+_linked\.id$/) { + unlink($lonids.'/'.$linkedfile); + } + } + } else { + unlink($lonids.'/'.$filename); + } } } closedir(DIR);