Class Definition Question

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
 
W

William Ryan

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
 
T

Tu-Thach

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
 
Z

Z GIRL

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
 

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