core: always set the user explicitly in the session.
Don't copy the user from the current context.

(cherry picked from commit f4b97f58190c8423a90a11e4617dd08d468cdedb)