When a user logs in to my asp.net site, I use the following code:
FormsAuthentication.RedirectFromLoginPage(userid, false);
As I often need to use userid, I can then get the user ID:
string userid = System.Web.HttpContext.Current.User.Identity.Name;
Now I also want to show the registered username on each page, and so I ask the question where is the best place to put the username if I need to use it on every page. User.Identity.Name is already being used by the user id, so I cannot use it. Another solution would be to get the username from the database on each page, but this seems like a bad solution.
So: the best way to use sessions to store a username?
source
share