Login via Java Action

I'm trying to use a Java Action to login a user, by calling com.mendix.core.Core.login(Username, Password); This gives me a ISession object. However, the user in the browser remains an anonymous user. How can I change the session of the current user in the browser through a Microflow or Java action?
1 answers

Since it didn't work with a Java action, I tried using a widget. I modified the LoginButton widget to be able to do what I wanted. The modification involves the On-Login-Microflow returning the username which is used to log in. If the microflow returns empty, no login attempt is done.