more error checking in the cookie reading