Index: WeBWorK/Cookie.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/Cookie.pm,v retrieving revision 1.1.6.1 diff -u -r1.1.6.1 Cookie.pm --- WeBWorK/Cookie.pm 13 Aug 2007 22:53:43 -0000 1.1.6.1 +++ WeBWorK/Cookie.pm 29 Aug 2009 19:27:10 -0000 @@ -39,6 +39,7 @@ BEGIN { if (MP2) { require Apache2::Cookie; + require APR::Request::Error; Apache2::Cookie->import; push @WeBWorK::Cookie::ISA, "Apache2::Cookie"; } else { Index: WeBWorK/Authen.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/Authen.pm,v retrieving revision 1.62.2.1 diff -u -r1.62.2.1 Authen.pm --- WeBWorK/Authen.pm 13 Aug 2007 22:53:43 -0000 1.62.2.1 +++ WeBWorK/Authen.pm 29 Aug 2009 19:27:11 -0000 @@ -618,14 +618,32 @@ my $courseID = $urlpath->arg("courseID"); - # AP2 - Apache2::Cookie needs $r, Apache::Cookie doesn't - my %cookies = WeBWorK::Cookie->fetch( MP2 ? $r : () ); - my $cookie = $cookies{"WeBWorKCourseAuthen.$courseID"}; - + my $cookie = undef; + if (MP2) { + use APR::Request::Error; + my $jar = undef; + eval { + $jar = $r->jar; #table of cookies + }; + if (ref $@ and $@->isa("APR::Request::Error") ) { + debug("Error parsing cookies, will use a partial result"); + $jar = $@->jar; # table of successfully parsed cookies + }; + if ($jar) { + $cookie = $jar->get("WeBWorKCourseAuthen.$courseID"); + }; + } else { + my %cookies = WeBWorK::Cookie->fetch(); + $cookie = $cookies{"WeBWorKCourseAuthen.$courseID"}; + if ($cookie) { + debug("found a cookie for this course: '", $cookie->as_string, "'"); + $cookie = $cookie->value; + } + } + if ($cookie) { - debug("found a cookie for this course: '", $cookie->as_string, "'"); - debug("cookie has this value: '", $cookie->value, "'"); - my ($userID, $key) = split "\t", $cookie->value; + debug("cookie has this value: '", $cookie, "'"); + my ($userID, $key) = split "\t", $cookie; if (defined $userID and defined $key and $userID ne "" and $key ne "") { debug("looks good, returning userID='$userID' key='$key'"); return $userID, $key;