session - read and write values: HttpContext.Current.Session

What is the best way to read and write a value to a session - is the below correct to write to?

HttpContext.Current.Session["username"] = Convert.ToString(dr["us_username"]);
tbaseflugAsked:
Who is Participating?
 
Carl TawnSystems and Integration DeveloperCommented:
Yes, what you have is fine.
0
 
mrichmonCommented:
That is fine.  Or you can create an object if you are storing more than just a username.

Although if just a username you should consider using the built in principals like User.Identity.Name - rather than storing your own version of loginin
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.