Session Variable Madness

T

Todd

Here's one that has been stumping people:

I'm writing in ASPX with VB.NET

On the login page I set the entered usename text to a session
variable.
************************************************************************
Private Sub lbtnSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles lbtnSubmit.Click
Dim bolLogin As Boolean

If Page.IsValid Then
Session("ctc_username") = txtUsername.Text.ToUpper()
Response.Redirect("acchist.aspx")
End If
End Sub
*************************************************************************
On the next/called page "acchist.aspx" I assign the session variable
to the text of lblUser.
*************************************************************************
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If Page.IsPostBack Then

Else
lblUser.Text = Session("ctc_username")
End If
End Sub
*************************************************************************
Here's where the strange behavior starts. In IE6 the session variable
will display in lblUser on the page load. However, if the page is
refreshed the session variable disappears from both lblUser and the
page trace. If the page is repeatedly refreshed the session variable
will begin to alternate as there or not. In Netscape 7.0 the first
time that the called page loads the session variable doesn't appear
and then begins with the smae behavior on repeated refresh.

You can check it out at the following address:
www5dev.nau.edu/ctc/registration/login.aspx
Put in any username and password.

Does anyone know what is causing this and/or how to get the session
variable to remain consistent?

Thanks,
Todd Bohlander
Ancillary Systems Development
Information Technology Services
Northern Arizona University
 
D

Daniel Bass

Todd,

typically a refresh means that you are no longer in the same session, and so
results in the cache being flushed. why it's reappearing after than I'm not
sure.

Why not assign the name to a text box or a label that has the
EnableViewState enabled (default) and set them visible=false if you don't
want to see them. This should provide more consistency in this case.

hope this helps.
Dan.




Here's one that has been stumping people:

I'm writing in ASPX with VB.NET

On the login page I set the entered usename text to a session
variable.
************************************************************************
Private Sub lbtnSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles lbtnSubmit.Click
Dim bolLogin As Boolean

If Page.IsValid Then
Session("ctc_username") = txtUsername.Text.ToUpper()
Response.Redirect("acchist.aspx")
End If
End Sub
*************************************************************************
On the next/called page "acchist.aspx" I assign the session variable
to the text of lblUser.
*************************************************************************
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If Page.IsPostBack Then

Else
lblUser.Text = Session("ctc_username")
End If
End Sub
*************************************************************************
Here's where the strange behavior starts. In IE6 the session variable
will display in lblUser on the page load. However, if the page is
refreshed the session variable disappears from both lblUser and the
page trace. If the page is repeatedly refreshed the session variable
will begin to alternate as there or not. In Netscape 7.0 the first
time that the called page loads the session variable doesn't appear
and then begins with the smae behavior on repeated refresh.

You can check it out at the following address:
www5dev.nau.edu/ctc/registration/login.aspx
Put in any username and password.

Does anyone know what is causing this and/or how to get the session
variable to remain consistent?

Thanks,
Todd Bohlander
Ancillary Systems Development
Information Technology Services
Northern Arizona University
 
A

Anon

Are you using web farm or web gardening? If so what type of session state
are you using?
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top