Fixed bug with invalid credentials being saved on the cookie