Print Page | Close Window

Sessions in App_Code

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=25826
Printed Date: 28 March 2026 at 4:08am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Sessions in App_Code
Posted By: VBScript
Subject: Sessions in App_Code
Date Posted: 13 June 2008 at 11:05am
Does anyone know how to access sessions  from a function which is in a module in the App_Code folder?

-------------
http://www.james-r.co.uk" rel="no follow - James
http://www.gotrillian.com/?4498-20" rel="no follow - Trillian - M



Replies:
Posted By: VBScript
Date Posted: 13 June 2008 at 11:13am
I've found a solution to my own problem

In a module at the following namespace
Imports System.Web.SessionState

Add the following public variable
Public Session As HttpSessionState = HttpContext.Current.Session


You can now use sessions normally

'Set method
Session("var1") = "Hello World")

'Get method
strText = Session("var1")




-------------
http://www.james-r.co.uk" rel="no follow - James
http://www.gotrillian.com/?4498-20" rel="no follow - Trillian - M


Posted By: Videoediting
Date Posted: 07 August 2008 at 12:43pm
Set the value
System.Web.HttpContext.Current.Session["Key"] =value;

Get the value
value=System.Web.HttpContext.Current.Session["Key"].tostring():

Hope this helps!!!

Cheers,

SPBig%20smile
http://www.videoediting-direct.co.uk



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net