Class Definition Question

  • Thread starter Thread starter Z GIRL
  • Start date Start date
Z

Z GIRL

Hi

I was to create a generic shared class to check for existance of
a user login id. I'm just not sure how to do this correctly.

This is what I have

Public Class User_Utility

Shared Function CheckSession() As boolean
if Session.Item("nCustID") is nothing then
CheckSession = False
else
CheckSession = True
end if
End function


What do i need to import or associate with this class
in order to access the Session object?
I tried Imports System.Web.SessionState
but that didn't work.

Oh one other question. A shared class will only check the session
in scope, not any session variable right?

Thanks in advance
 
Your class can't access it AFAIK. Instead, create a Property for the class

Public Property nCustId() As string

Get

Return _nCustId

End Get

Set(ByVal Value As String)

_nCustId = Value

End Set

End Property


Then reference the property. YOu may want to set the property in the
constructor so you'll know it's set.

Public Sub New(ByVal CustomerID as String)
me.CustID = CustomerID
'or _nCustId = CustomerID
End Sub
 
You need to use the HttpContext.Current.Session object.
This is in the System.Web namespace. Remember to add the
System.Web.dll to your references.

Tu-Thach
 
thanks Tu-Thach.

ydm
Tu-Thach said:
You need to use the HttpContext.Current.Session object.
This is in the System.Web namespace. Remember to add the
System.Web.dll to your references.

Tu-Thach
 
Back
Top