Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto login after registration

Status
Not open for further replies.

primagic

IS-IT--Management
Jul 24, 2008
476
GB
I have the following snippet of code which registers a user and adds the record to the database and works fine. You will see it redirects to a page which is in a secured directory. How can I auto login the user after they have registered so that they can access the page.

Code:
If rbHomeBody.Checked = True Then
                        Me.hdnMembershipType.Value = "3"

                        'Add record here
                        Dim ConnString As [String] = ConfigurationManager.ConnectionStrings("quickbabysitConnectionString").ConnectionString
                        Dim con As New SqlConnection(ConnString)
                        Dim cmd As New SqlCommand()
                        cmd.CommandType = CommandType.StoredProcedure
                        cmd.CommandText = "AddNewParentRegistration"
                        cmd.Parameters.Add("@Firstname", SqlDbType.VarChar).Value = txtFirstname.Text.Trim()
                        cmd.Parameters.Add("@Surname", SqlDbType.VarChar).Value = txtSurname.Text.Trim()
                        cmd.Parameters.Add("@EmailAddress", SqlDbType.NVarChar).Value = txtEmail.Text.Trim()
                        cmd.Parameters.Add("@Password", SqlDbType.NChar).Value = txtPassword.Text.Trim()
                        cmd.Parameters.Add("@AddressLine1", SqlDbType.VarChar).Value = txtAddress1.Text.Trim()
                        cmd.Parameters.Add("@AddressLine2", SqlDbType.VarChar).Value = txtAddress2.Text.Trim()
                        cmd.Parameters.Add("@AddressLine3", SqlDbType.VarChar).Value = txtAddress3.Text.Trim()
                        cmd.Parameters.Add("@AddressLine4", SqlDbType.VarChar).Value = txtAddress4.Text.Trim()
                        cmd.Parameters.Add("@Town", SqlDbType.VarChar).Value = txtCity.Text.Trim()
                        cmd.Parameters.Add("@Postcode", SqlDbType.VarChar).Value = txtPostcode.Text.Trim()
                        cmd.Parameters.Add("@ContactPhone", SqlDbType.VarChar).Value = txtPhone.Text.Trim()
                        cmd.Parameters.Add("@NumberKids", SqlDbType.Decimal).Value = ddlKids.SelectedValue.Trim()
                        cmd.Parameters.Add("@MembershipType", SqlDbType.Int).Value = hdnMembershipType.Value.Trim()


                        Dim ParentID As New SqlParameter("@ParentID", SqlDbType.Int)
                        ParentID.Direction = ParameterDirection.Output
                        cmd.Parameters.Add(ParentID)

                        cmd.Connection = con


                        Try
                            con.Open()
                            cmd.ExecuteScalar()


                        Catch ex As Exception
                            Throw ex
                        Finally
                            con.Close()
                            con.Dispose()
                        End Try


                        ' send_email()


                        pnlRegParent.Visible = False
                        pnlSuccess.Visible = True
                        Response.AddHeader("Refresh", "4;URL=parents/booking.aspx")
                    End If
                End If
            End If
        Else
            Me.lblTermsValidation.Visible = True
        End If
    End Sub
 
You can store a cookie on the person's machine and read that if it exists. Then if it exists, redirect to the proper page. This is one way of doing it...

Walt
IT Consulting for Robert Half
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top