Use the code you pasted as that is the correct way for an ASP.NET application.
Locate your Virtual Directory for that application and remove anonymous perm for IIS to be able to authenticate the user and return a correct value.
To store the information you would have to choose a storage type , Database (ms Access or SQL) and then create tables and columns to store the info there.