Fixed crash in some cases when invalid session cookie was present.

getCookie in such cases had wrong behavior – even after the new session was created, old cookie was still returned.