Fixing this to work when called from POST /session/ and elsewhere