Hi I have a web page, which has a login corner. When someone logs in and clicks the "Go" button, a class called Security gathers the users details and posts it back to the same page, under a session variable called "User"
VB Code:
Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.Click 'Login into the system Dim l As New Security() Dim Outcome As PPPL.Security.LoginOutcome Outcome = l.DoLogin(Login.Text, Password.Text) Select Case Outcome Case Security.LoginOutcome.lgBADLOGIN Case Security.LoginOutcome.lgBADPASSWORD Case Security.LoginOutcome.lgINACTIVE Case Security.LoginOutcome.lgLOCKED Case Security.LoginOutcome.lgLOGGEDIN Session("User") = l If l.IsAdmin Then EnableFixtureEntry(True) Else EnableFixtureEntry(False) End If Label3.Text = "You are logged in as " & l.User End Select End Sub
When the page postsback to itself, I need that session variable saved, so that I can access it. Trouble is when I try to retrieve it, I get a null value.
VB Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here If IsPostBack Then 'Determine if the user is logged in. Dim l As New Security() l = Session("User") If Not l Is Nothing Then pnlPredictions.Controls.Add(New LiteralControl(l.User)) End If End If End Sub
Problem is that when it gets to evaluating whether l Is Nothing, it always returns true. Please can someone help me?




Reply With Quote