Session variable in a module....

  • Thread starter Thread starter WilsonSmith
  • Start date Start date
W

WilsonSmith

When I use a session variable in a module, it says "Name session is not
declared". Is it not possible to use session variable in module?

Wilson
 
WilsonSmith said:
When I use a session variable in a module, it says "Name session is not
declared". Is it not possible to use session variable in module?

Here's a quiz for you:

1) In a page, why (and how) is "Session" defined?
2) In what way does that differ from a module?

--
John Saunders
johnwsaundersiii at hotmail


Answers:

1) In a page (or user control), the name "Session" refers to "this.Session"
(or Me.Session in VB.NET). This is the same as Context.Session, which means
this.Context.Session.
2) Anywhere else, "Session" is undefined unless you define it. However, you
can get access to the same value by referring to
System.Web.HttpContext.Current.Session.
 
When you want to use session but you are not in an aspx page or ascx ( web
user control ), you need to use the code
httpcontext.Current.Session



this will work in module or class.



Thanks,

Tee
 
Thank you so much.
Wilson


Tee said:
When you want to use session but you are not in an aspx page or ascx ( web
user control ), you need to use the code
httpcontext.Current.Session



this will work in module or class.



Thanks,

Tee
 
Back
Top