How to change Cookie Processor to LegacyCookieProcessor in tomcat 8

Case 1: You are using Standalone Tomcat & have access to change files in tomcat server

Please follow answer by @linzkl

Case 2: You are using Standalone Tomcat but you don't have access to change files in tomcat server

Create a new file called context.xml under src/main/webapp/META-INF folder in your application & paste the content given below

<?xml version="1.0" encoding="UTF-8"?> 
<Context>
  <WatchedResource>WEB-INF/web.xml</WatchedResource>
  <WatchedResource>WEB-INF/tomcat-web.xml</WatchedResource>
  <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource> 
  <CookieProcessor className="org.apache.tomcat.util.http.LegacyCookieProcessor" />
</Context>

When you deploy your application in Standalone Tomcat, the context.xml file you placed under META-INF folder will override the context.xml file given in tomcat/conf/context.xml

Note: If you are following this solution, you have to do it for every single application because META-INF/context.xml is application specific

Case 3: You are using Embedded Tomcat

Create a new bean for WebServerFactoryCustomizer

@Bean
WebServerFactoryCustomizer<TomcatServletWebServerFactory> cookieProcessorCustomizer() {
    return new WebServerFactoryCustomizer<TomcatServletWebServerFactory>() {

        @Override
        void customize(TomcatServletWebServerFactory tomcatServletWebServerFactory) {
            tomcatServletWebServerFactory.addContextCustomizers(new TomcatContextCustomizer() {
                @Override
                public void customize(Context context) {
                    context.setCookieProcessor(new LegacyCookieProcessor());
                }
            });
        }
    };
}

You can try in context.xml

<CookieProcessor className="org.apache.tomcat.util.http.LegacyCookieProcessor" />

reference: https://tomcat.apache.org/tomcat-8.0-doc/config/cookie-processor.html