Hi Kulrom, I did exactly as you said but it still doesn't work. Am I declaring these session state variables in the wrong place? Here are my code snippets:
Global.asax.vb file:
[SIZE=2][COLOR=#0000ff]
Imports[/COLOR][/SIZE][SIZE=2][COLOR=#800080] System.Web.SessionState[/COLOR]
[/SIZE][SIZE=2][COLOR=#0000ff]Imports[/COLOR][/SIZE][SIZE=2][COLOR=#800080] System.Web[/COLOR][/SIZE]
[SIZE=2][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2][COLOR=#800080] Session_Start([/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2][COLOR=#800080] sender [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE][SIZE=2][COLOR=#800080], [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2][COLOR=#800080] e [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#800080] EventArgs)[/COLOR]
Session("LoggedIn") = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Boolean[/COLOR][/SIZE][SIZE=2]()
Session("LoggedIn") = [/SIZE][SIZE=2][COLOR=#0000ff]False
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE][/SIZE]
In the HTML section of my frmLogin.aspx file:
sub page_load(sender As Object, e As System.EventArgs)
Dim conn as SqlConnection = New SqlConnection("server=(local);database=APMS;Trusted_Connection =yes")
Dim comm as SqlDataAdapter = new SqlDataAdapter("select * from UserData", conn)
Dim ds as new Dataset() comm.fill(ds,"Part")
end sub
sub cmd_login(sender As Object, e As System.EventArgs)
Dim conn as SqlConnection = New SqlConnection("server=(local);database=APMS;Trusted_Connection =yes")
Dim comm1 As SqlCommand = New SqlCommand("select * from UserData where UserID = '"& txtUserID.text &"' and Password = '"& txtPassword.text &"' ", conn)
Dim myReader As SqlDataReader Dim blnflag As Boolean = False
Conn.Open()
myReader = comm1.ExecuteReader
While myReader.Read()
Session("LoggedIn") = True
Session("UserName") = myreader.item("FName")
blnflag = True
response.redirect("franav.htm")
End While
If blnflag = False Then
lblMessage.Text = "Incorrect User ID or Password. Please try again."
End If
conn.close()
End Sub
fraNav is a frameset I use to hold my webforms. I put the folllowing code at the very top of the HTMl section, before the DOCTYPE, and html and head tags, like this:
<% If Session ("LoggedIn") = False Then
Response.Redirect("frmLogin.aspx")
End If
%>
At the top of the HTML section of frmHome.aspx, one of the webforms in fraNav, I have the same code.
At the top of the HTML Section of frmNav.aspx, another one of the webforms in fraNav, I have the same code. The logout hyperlink on this form has NavigateURL = "frmLogout.aspx" and Target ="_parent"
At the top of the frmLogout.aspx , again before the HTML tags, I have:
<% Session("LoggedIn") = False %>
After all this, when I click the Back button on my browser, I can still see the previous pages. This really sucks. Please tell me what I am doing wrong.