Create a session (and thus set a session cookie) only if you need it