Link to home
Start Free TrialLog in
Avatar of demerg
demerg

asked on

Asp.net 3.5 VB Forms Authentication Login and session variables problem

Hi

I have an asp.net 3.5 Visual Basic forms authentication application where I use a login form to query a SQL Server 2005 Database.

If the login parameters are accepted, I create several session variables in the login code behind after querying the database…

Session("UserID") = (customReader("IDNum"))
Session("UserFName") = (customReader("FName"))
Session("UserLName") = (customReader("LName"))
Session("UserEmail") = (customReader("Email"))

And then proceed to open the session on the default page …

FormsAuthentication.RedirectFromLoginPage(Session("UserID"), True)
Response.Redirect("default.aspx")

The bizzar occurance is that on no set time or action from any user, all of a sudden the Default Page which has 2 gridviews that rely on the Session("UserID") to populate themselves return 0 records, even though they just had records in them. What is really odd is the login authentication is still active and the login control on the default page is still showing the Session("UserID").

When the user loggs out and then back again things are back to normal but the same scenario can reoccur at any time.

The web.config is set the forms authentication mode and I have the timeout set to several hours.

Am I doing something wrong loading the session variables?
Why does the site function perfectly and then all of a sudden, the records in the Gridviews disappear and the authentication is still good?

I hope someone can help with this as this is really causing some problems
Avatar of radcaesar
radcaesar
Flag of India image

FormsAuthentication.SignOut();

And Clear your sessions on page unload.
Avatar of demerg
demerg

ASKER

Hi RadCaesar

Not sure if I understand what you are suggesting.

My problem is that the application is losing the session variables without any reason. I don't what to logout, I am having problems where the session variables are being lost after the user logs on.

How is clearing them and signing out going to help with this problem?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of radcaesar
radcaesar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of demerg

ASKER

Many Thanks RadCaesar