Session Variables in Modules

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
 
M

Mark Fitzpatrick

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
 
B

Brandon Potter

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
 
B

bruce barker

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top