Making users log back in to site

Tinbeard

Member
Joined
May 30, 2005
Messages
16
Location
UK
Programming Experience
1-3
I've created a website with a section that requires visitors to login to access certain company data.
At the moment the login works fine and if the user ends the session by clicking the 'Log Out' button, they are forced to login again if they want to access these pages again.

The problem is that if a user browses away from the site whilst they have an active session, they can come back to the secure pages without having to login again.

How do I destroy the session if they happen to browse away without logging out first ?

I'm using forms authentication and ending the session using FormsAuthentication.SignOut() when they hit the log out button
 
You can always check a session variable to see if it still contains data that was set at login. Put this in the Page_Load event for each of your secure pages and redirect if the variable no longer contains valid data. I usually set up a "LoggedIn" session variable upon successful login from the client. Just check this on each secure page.

Hope that helps,
Blokz
 
Back
Top