469,282 Members | 1,666 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

Session variable in a module....

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


Nov 18 '05 #1
3 4134
"WilsonSmith" <WS********@hotmail.com> wrote in message
news:eQ*************@TK2MSFTNGP11.phx.gbl...
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.
Nov 18 '05 #2
Tee
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


"WilsonSmith" <WS********@hotmail.com> wrote in message
news:eQ*************@TK2MSFTNGP11.phx.gbl...
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


Nov 18 '05 #3
Thank you so much.
Wilson
"Tee" <th*@streamyx.com> wrote in message
news:u#**************@TK2MSFTNGP09.phx.gbl...
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


"WilsonSmith" <WS********@hotmail.com> wrote in message
news:eQ*************@TK2MSFTNGP11.phx.gbl...
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



Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Sean Pinto | last post: by
1 post views Thread by Scott Wickham | last post: by
9 posts views Thread by Randy | last post: by
4 posts views Thread by semsem22 | last post: by
4 posts views Thread by Cirene | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.