Obtaining Session information in a Class Library

  • Thread starter Thread starter Fred Nelson
  • Start date Start date
F

Fred Nelson

Hi:

I'm writng a VB.NET web application and I would like to be able to obtain
session information within my class library rather than obtain the session
ID and pass it as a parameter to functions within the class lib.

Presently I must do something like:

dim mysess as string = session.sessionid

dim myfunctionlib as (something)

myfunct1.procadd(mysess)

since I can't get the session ID in the class library.

Is there a way to do this - any help would be GREATLY appreciated!

Thanks,

Fred
 
Fred, you can access the Session from a class library like so:

Dim sessionID as String = HttpContext.Current.Session.SessionId

Essentially, you need to use HttpContext.Current.Session to get a
reference to the session object for the current user. (Note that your
class library will need to Import the System.Web namespace...)

Happy Programming!

--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
 
Back
Top