I am using Login Control available in ASP.NET 2.0 in the login page. Once the user is authenticated successfully against database, I am redirecting the user to home.aspx. Here,
yes as Andrew said, session is the primary place to store sensitive data.
but why a user's name is sensitive ? You can save it in cookie and print it in your home.aspx whenever user comes in.
EDIT : You can use cookies in ASP.NET like that :
// Setting cookie :
Response.Cookies["UserName"].Value = "Erhan";
Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(7); // Persists 1 week
// Getting cookie :
string username = string.Empty;
if(Request.Cookies["UserName"] != null)
{
username = Server.HtmlEncode(Request.Cookies["UserName"].Value);
}
NOTE : Cookies stored at client's machine. so you should not use them to store sensitive data.