21 September 2011

Login via software

Shared Function LoginUser(ByVal userName As String, ByVal password As String) As Boolean

        Dim res As Boolean = Membership.ValidateUser(userName, password)

        If res Then
            Response.Cookies.Remove(FormsAuthentication.FormsCookieName)
            FormsAuthentication.SetAuthCookie(userName, False)
        End If

        Return res

    End Function