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
Entries in this series:
- ASP.NET Sessions Part 1
- ASP.NET Sessions Part 2 - accessing session state variable data
- ASP.NET Sessions Part 3 - Maintaining the Session Data Across Multiple Requests
- ASP.NET Sessions Part 4 - Configuring how the Session Variable Data is Stored on the Server
- ASP.NET Sessions Part 5 - How Long Does a Session Last?
- ASP.NET Sessions Part 6 - Abandoning a Session
No related posts.
Tags: .NET, .NET 2.0, ASP.NET, ASP.NET Sessions, Session, Sessions, SessionState, State











