Remember last login name in login screen

Hello,

is there a way to remember the last user name that was logged in and to preset this value when reopening the login screen? The password field should remain empty.

Greetings
Andreas

Hi, you can save it in cookies:

import com.haulmont.cuba.web.App;

    @Inject
    protected App app;

    String encodedLogin = URLEncodeUtils.encodeUtf8(login);
    app.addCookie("APPNAME_LOGIN", StringEscapeUtils.escapeJava(encodedLogin));

Take a look at source code of LoginScreen in release 7.1. It actually contains similar logic.

1 Like

Hi @minaev,

that’s it. Thanks :slight_smile: