Quick fix for “Expected token not present” in Apache2::Cookie
247
post-template-default,single,single-post,postid-247,single-format-standard,bridge-core-3.0.1,qodef-qi--no-touch,qi-addons-for-elementor-1.5.3,qode-page-transition-enabled,ajax_updown,page_not_loaded,,vertical_menu_enabled,side_area_uncovered_from_content,qode-theme-ver-28.7,qode-theme-bridge,disabled_footer_top,qode_header_in_grid,wpb-js-composer js-comp-ver-6.8.0,vc_responsive,elementor-default,elementor-kit-6

Quick fix for “Expected token not present” in Apache2::Cookie

Quick fix for “Expected token not present” in Apache2::Cookie

A client’s website of mine had been running fine for many years until a few weeks ago. Certain users of IE started getting this error: “Expected token not present” and were no longer able to login. My guess is that the design team switched some elements from Flash to HTML5/jQuery and introduced some bad cookie code in Javascript. Not wanting to dive into a bunch of JS or jQuery code, I looked into solving the problem on the server side.

I tracked it down to Apache2::Cookie rejecting cookies with invalid formatting and then exiting. So I took the advice on this page and made a change the fetch method of Cookie.pm:

#my $jar = $req->jar or return;
#...avoid cookie parse error "Expected token not present"
my $jar = eval {$req->jar()} || $@->jar; # if fail, parse the cookie anyway
return unless $jar;

I don’t like making direct changes to installed modules like this, but in this case I made an exception. The website in question will be put on a PHP platform soon and it wasn’t worth spending more time on this problem.



Mastodon