Java Intro to Java Web Development with Spark Diving into Web Development Cookies

If the username contains a whitespace character such as " ", I get a 500 internal error. Is there any way to fix this?

This is a part of the error message I get:

[qtp694881261-17] ERROR spark.http.matching.GeneralError - 
java.lang.IllegalArgumentException: RFC6265 Cookie values may not contain character: [ ]

Line where the error starts:

at com.teamtreehouse.courses.Main.lambda$main$1(Main.java:25)

Line causing error:

res.cookie("username", username);

Example name: James Roger