automatic logout

cfisher440

Well-known member
Joined
Oct 11, 2005
Messages
73
Programming Experience
1-3
Upon logging onto my application, I want to create a timestamp for the user (say an hour). When the timestamp expires it logs them off the application and brings them back to the log in screen.

Just wondering what a good method of doing this would be.
 
To be more specific

The form has a Log in and password textbox and two radio buttons.
when they select the button to sign in, depending on the radio button selected, it will take them to that page.

When they log in a checkbox in the database is checked to signify they are logged in. After say two hours of inactivity, if they click any other link on the site, I would like it to log the person off (uncheck the checkbox) and send the person back to the log in page.

Here is the code for the button to log in

VB.NET:
Private Sub cmdGoToWork_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGoToWork.Click
        Try
            cmd.CommandType = CommandType.Text
            'Below Set Select Command (what data you want from the database you are connecting to)
            'Set UserNAME to Session Var to save it instead of personal #
            Session("UName") = txtUserName.Text
            cmd.CommandText = "Update tblUsers set WhyHere='" & rdbToDo.SelectedValue & "', LoggedIn=True where LanID='" & System.Environment.UserName & "'"
            'Set the connection to a database
            cmd.Connection = con
            'Initialize a new dataadaptor
            Dim da As New OleDbDataAdapter
            'Set the select command text = to the query we wrote 
            da.SelectCommand = cmd
            con.Open()
            da.SelectCommand.ExecuteNonQuery()
            con.Close()
            Select Case rdbToDo.SelectedValue
                Case "Answer"
                    Session("GOHERE") = "answer.aspx"


                Case "Work"
                    Session("GOHERE") = "WorkOutstandings.aspx"

            End Select
            Response.Redirect(Session("GOHERE"))
        Catch ex As Exception
            Response.Write(ex.ToString)
        End Try


    End Sub

The app works just fine, but people forget to logoff and that messes up some of my statistics I pull up on the site.

Any questions / comments / ideas would be greatly appreciated.
 
Last edited:
Back
Top