how to use a session variable into a class?

B

Bob

Hi,

in order to check the value of a session variable in each page, i want to
put the code into a shared sub like this:

Public Class myclass
Public Shared Sub checksession()
If Session("myvar") = "" Then
Response.Redirect("mypage.aspx")
End If
End Sub
End Class

and then using: myclass.checksession()

In code-behind, "Session" must not be defined, but here in the class, i get
the error that the "Session" is not defined.

Thanks for help
Bob
 

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