i am trying to write code for login system .. but .. i know how to work normally ..
nut how to create ..perfect i dont know ,
First search "login system" including the quotes.
There are many articles to get you started.
And any decent one will tell you to not bother unless you have to.
Rely on an external authentication system instead. Be if facebook, twitter, google, OpenID, etc. etc. or an existing SSO engine running within your existing environment.
All are almost certainly more secure than anything you can come up with.