The THEMEMODE cookie is being set without an expiration date, which causes it to behave like a session cookie. This means the cookie is deleted when the browser is closed.
Update the following code might work