In this case we are going to use a cookie to store the
username logged into de system in case the checkbox “Recordar usario” is
checked.
To set the cookie we are going to use this function called
when clicked the button “Entrar”, and after success to log :
In this function the cookie is created with the id 'accessCookie' and with the
username 'user', and also with an expiration delay of 30 days. In case the user select not to
remember the username then the delay is set for one milisec which causes to
delete the cookie.
To load the user stored in the cookie we use the
afterrender event for the login view, which tries to read the cookie and if it
exists then the username is loaded into the user name field, and the “Recordar
usuario” check box is checked.