How to make Spring remember user after he logins until he presses ‘logout’ button?

I’m developing small app using Spring. I have created register form and it writes all data in MongoDB.

Also I have login form. You type in login and pass, it finds user with this username in DB, if password the same, you login. In my case it just redirects you to home page if password is right. But how to make website remember you or something? And only when you press ‘logout’ it should demand you to login again?

Login process

Register process

Thank you!