Fixed issue where the session cookie may not be set in some cases (fixes
issue #3)