authentication works..now i need to remember!
I'm a newbie to asp.net...
Just creating a simple login page...
I have the user name nand passwords stored in a database table.
On the web form I have the text boxes and a check box to "Remember my Password" so they get logged in without having to authenticate themselves.
How do I implement this "Remember Me" feature. I just want it so that when a user clicks this he / she doesnt have to type in a user name and password.
I know it has to do with cookies, but can anyone provide example code or steps on how to do this ?
Here is my authentication code:
VB Code:
<%@ Page Language="VB" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">
Sub Page_Load
Dim strLinkPath As String
If Not IsPostBack Then
strLinkPath = String.Format( "Register/Register.aspx?ReturnUrl={0}", _
Request.Params( "ReturnUrl" ) )
lnkRegister.NavigateUrl = String.Format( strLinkPath )
End If
End Sub
Sub Button_Click( s As Object, e As EventArgs )
If IsValid Then
If DBAuthenticate( txtUsername.Text, txtPassword.Text ) > 0 Then
FormsAuthentication.RedirectFromLoginPage( txtUsername.Text, False )
End If
End If
End Sub
Function DBAuthenticate( strUsername As String, strPassword As String ) As Integer
Dim conMyData As SqlConnection
Dim cmdSelect As SqlCommand
Dim parmReturnValue As SqlParameter
Dim intResult As Integer
conMyData = New SqlConnection( "Server=blah;UID=IMS;PWD=blah123;Database=blah" )
cmdSelect = New SqlCommand( "DBAuthenticate", conMyData )
cmdSelect.CommandType = CommandType.StoredProcedure
parmReturnValue = cmdSelect.Parameters.Add( "RETURN_VALUE", SqlDbType.Int )
parmReturnValue.Direction = ParameterDirection.ReturnValue
cmdSelect.Parameters.Add( "@username", strUsername )
cmdSelect.Parameters.Add( "@password", strPassword )
conMyData.Open()
cmdSelect.ExecuteNonQuery()
intResult = cmdSelect.Parameters( "RETURN_VALUE" ).Value
conMyData.Close()
If intResult < 0 Then
If intResult = -1 Then
lblMessage.Text = "Username Not Registered!"
Else
lblMessage.Text = "Invalid Password!"
End If
End If
Return intResult
End Function
</script>
And I can get that part (although even after authentication it does not redirect the user :(. Now how do I implement the "remember my password" feature??????