It is coming out of the box from the Marketplace Module, Administration.
Using the authentication widgets will provide all you need.
The logic to validate username and password is handled by mendix.
Just drop and drop the username and password authentication widgets and signin button on your page and you are set
Hey, you can use Java action called: JVA_findMember from module auto-login .
it will take 2 parameter . user name , password and return boolen falg