Automatic login like Mendix Mobile App

We would like to provide the ability to remember a user and let them automatically login until they explicitly logout. In fact the same functionality as in the "Mendix Mobile" App. How can we achieve this?
2 answers

You can create an anonymous homepage with microflow buttons. You can retrieve a user in a microflow and then create a java action to log the user in to the application.

Take a look at the sso java action implementation which creates a session based on a user without having to add a password.

Something like:

    public static boolean createSession(IMxRuntimeRequest request, IMxRuntimeResponse response, String username) throws Exception {
    IContext context = Core.createSystemContext();
    IUser user;

        user = Core.getUser(context, username);

    //unknown user?
    if (user == null) {
        return false;

    //known user
    ISession session = Core.initializeSession(context, user, null, "");

    // sesison initialized, make sure the user (browser) knows about it through cookies
    if (session != null) {
        /** create cookies and redirect: String key, String value, String path, String domain, int expiry */
        response.addCookie("XASSESSIONID", session.getId().toString(), "/", "", -1);
        response.addCookie("XASID", "0."+String.valueOf(Core.getXASId()),"/", "", -1);

        Core.getLogger("LoginHelper").info("User '" +username + "' has been authenticated.");

        // redirect the user to the index.html, now with session cookie
        response.addHeader("location", "..");
        return true;
    else {
        return false;

Hello Everyone,

My question is that,I’ve a mendix application hosted on mindsphere.the application has 3 different users(Administrator,Anonymous and User).So when in the project security the “Anonymous Users” is off the page that displays to enter the mindsphere credential data does not appear and instead displays the login page directly.when this happens then we’ll not be able to extract the data in the mindsphere and display it in the mendix app.

So if we do the other way round i.e. if we turn on the “Anonymous Users” then the page that displays to enter the mindsphere credential data appears and the login page also appears and also it displays the mindsphere data but the twist here is that it is logged in as Admin and not the user himself.

Iam struck with this for almost a week now..Can someone help me with this?