title: Handling java.lang.IllegalArgumentException: caused by Control character in cookie value
body: <p>Recently I have deployed a web site where I store cookies in browser with product name as cookie value. But some products has control characters in their name. As a result when those product names are saved in cookie an IllegalArgumentException caused by Control character in cookie value thrown. </p>
  
  <pre><code> java.lang.IllegalArgumentException: Control character in cookie value or attribute.
          at org.apache.tomcat.util.http.CookieSupport.isHttpSeparator(CookieSupport.java:169)
          at org.apache.tomcat.util.http.Cookies.getTokenEndPosition(Cookies.java:493)
          at org.apache.tomcat.util.http.Cookies.doProcessCookieHeaderOriginal(Cookies.java:283)
          at org.apache.tomcat.util.http.Cookies.processCookieHeader(Cookies.java:233)
          at org.apache.tomcat.util.http.Cookies.processCookies(Cookies.java:141)
          at org.apache.tomcat.util.http.Cookies.getCookieCount(Cookies.java:107)
          at org.apache.catalina.connector.CoyoteAdapter.parseSessionCookiesId(CoyoteAdapter.java:1163)
          at org.apache.catalina.connector.CoyoteAdapter.postParseRequest(CoyoteAdapter.java:914)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:532)
          at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1081)
          at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658)
          at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
          at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566)
          at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
          at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
          at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  
  <p>Some idea is in my mind that I have to encode the name before store in the cookies.</p>
  
  <p>But the problem is that the many user already faced the problem cannot browse the site. </p>
  
  <p>Is there is any way to handling the exception without changing the cookie value or there is any way to delete the old cookies which were problematic or any other else. </p>