ASP.NET Sessions Part 2 – accessing session state variable data

This entry is part of a series, ASP.NET Sessions»

To add/set a session variable, from within code on a page, you can simply use

Session(“VariableName”) = Value

To reset it, you can set it to Nothing in VB.NET or null in C#

If you aren’t inside a page’s code, you can use the HTTPContext class to get the current context and access the session via that (more coming on HTTPContexts at some point in the future).  You can do this like…

HTTPContext.Current.Session(“VariableName”) = Value

No related posts.

Tags: , , , , , , ,

Leave a Reply