Session Variables in Modules

  • Thread starter Thread starter Gary
  • Start date Start date
G

Gary

I just tried to use a session variable in a module and it doesn't recognize
Session. We can't use session variables in modules?
Thanks,
G
 
You should be able to. You have to remember that Session is really a
shortcut for HttpContext.Current.Session. When you access the Session object
from something other than a web control or web form (such as a class that is
called by the web form) you have to access it through the HttpContext.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
 
I believe you can use

System.Web.HttpContext.Current.Session("key")

In modules to access session variables.

Or imports / using System.Web.HttpContext at the beginning of the module and
retrieve it normally.

Brandon
 
you really should not use modules with asp.net, unless you need global
shared memory. remember all variables (private or shared) not dim'd in a
function or subroutine are shared across all page requests (even concurent),
so you must use locking.


-- bruce (sqlwork.com)
 
Back
Top