Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

Remember me checkbox with Membership provider

$
0
0

I"m using the membership provider for login authentication. It is working and redirecting to the url in web.config. How do I make it check to see if the user checked the remember me checkbox, and see if there is a cookie in the browser?  How do I create the cookie?

 <asp:Login ID="Login1" runat="server" DestinationPageUrl="~/users/default.aspx"
        Width="303px"  PasswordRecoveryText="Forgot Password ?"
        PasswordRecoveryUrl="~/passwordrecovery.aspx" BackColor="#F7F6F3"
        BorderColor="#E6E2D8" BorderPadding="4" BorderStyle="Solid" BorderWidth="1px"
        Font-Names="Verdana" Font-Size="0.8em" ForeColor="#333333"
            CreateUserText="Click here to Register" CreateUserUrl="~/register.aspx"
            Height="140px"
            FailureText="Your login attempt was not successful. &lt;br /&gt;Please try again.">
        <TextBoxStyle Font-Size="Small" />
        <LayoutTemplate>
            <table cellpadding="4" cellspacing="0" style="border-collapse:collapse;">
                <tr>
                    <td>
                        <table cellpadding="0" style="height:140px;width:303px;">
                            <tr>
                                <td align="center" colspan="2"
                                    style="color:White;background-color:#5D7B9D;font-size:0.9em;font-weight:bold;">
                                    Log In</td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="UserName" runat="server" Font-Size="Small"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="UserNameRequired" runat="server"
                                        ControlToValidate="UserName" ErrorMessage="User Name is required."
                                        Font-Size="Small" ForeColor="Red" ToolTip="User Name is required."
                                        ValidationGroup="Login1">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="right"><span onmouseout="UnTip()" onmouseover="Tip('Your password is case sensitive', WIDTH, 100)">
                             <img alt="" src="./pics/help.gif" />
                         </span>
                                    <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="Password" runat="server" Font-Size="Small" TextMode="Password"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="PasswordRequired" runat="server"
                                        ControlToValidate="Password" ErrorMessage="Password is required."
                                        Font-Size="Small" ForeColor="Red" ToolTip="Password is required."
                                        ValidationGroup="Login1">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <asp:CheckBox ID="RememberMe" runat="server" Text="Remember me next time." />
                                </td>
                            </tr>
                            <tr>
                                <td align="center" colspan="2" style="color:Red;">
                                    <asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
                                </td>
                            </tr>
                            <tr>
                                <td align="right" colspan="2">
                                    <asp:Button ID="LoginButton" runat="server" BackColor="#FFFBFF"
                                        BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px" CommandName="Login"
                                        Font-Names="Verdana" Font-Size="Small" ForeColor="#284775" Text="Log In"
                                        ValidationGroup="Login1" Width="100px" />
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <asp:HyperLink ID="CreateUserLink" runat="server" NavigateUrl="~/register.aspx">Click here to Register</asp:HyperLink>
                                    <br />
                                    <asp:HyperLink ID="PasswordRecoveryLink" runat="server"
                                        NavigateUrl="~/passwordrecovery.aspx">Forgot Password ?</asp:HyperLink>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </LayoutTemplate>
        <LoginButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid"
            BorderWidth="1px" Font-Names="Verdana" Font-Size="Small"
            ForeColor="#284775" Width="100px" />
        <ValidatorTextStyle Font-Size="Small" />
        <InstructionTextStyle Font-Italic="True" ForeColor="Black" />
        <TitleTextStyle BackColor="#5D7B9D" Font-Bold="True" Font-Size="0.9em"
            ForeColor="White" />
    </asp:Login>

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Session("path") = ""

            If ((Not (Request.Cookies("UserName")) Is Nothing) _
                      AndAlso (Not (Request.Cookies("Password")) Is Nothing)) Then
                Login1.UserName = Request.Cookies("UserName").Value
                Login1.Attributes("value") = Request.Cookies("Password").Value
            End If
        End If
    End Sub


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>