Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. RememberMe option to remember only username using asp:login?

RememberMe option to remember only username using asp:login?

Scheduled Pinned Locked Moved C#
question
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NetRams
    wrote on last edited by
    #1

    Hi, I have created my application using asp:login control. I need to make the login control to remember only the username on next login. Any luck? - Rams.

    Be simple and Be sample.

    J 1 Reply Last reply
    0
    • N NetRams

      Hi, I have created my application using asp:login control. I need to make the login control to remember only the username on next login. Any luck? - Rams.

      Be simple and Be sample.

      J Offline
      J Offline
      John Ad
      wrote on last edited by
      #2

      Hi Rams, Refer to the following code that uses a CheckBox and gives the flexibility to the user to save the username: protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { CheckBox cek = (CheckBox)Login1.FindControl("RememberMe"); if (Request.Cookies["username"] == null Request.Cookies["username"].Value.ToString().Trim() == "") { cek.Checked = false; } else { Login1.UserName = Request.Cookies["username"].Value.ToString(); } } } protected void Login1_LoggingIn(object sender, LoginCancelEventArgs e) { CheckBox cek = (CheckBox)Login1.FindControl("RememberMe"); if (cek.Checked == true) { HttpCookie cookie = new HttpCookie("username"); cookie.Value = Login1.UserName; cookie.Expires = DateTime.Now.AddDays(1);//cookie Expires HttpContext.Current.Response.AppendCookie(cookie); } else { HttpContext.Current.Response.Cookies.Remove("username"); } cek.Checked = false; } //--- another way protected void Page_Load(object sender, EventArgs e) { if (Request.Cookies["MyCookie"] != null) { TextBox pass = (TextBox)Login1.FindControl("Password"); pass.Attributes.Add("value", Request.Cookies["MyCookie"]["password"]); Login1.UserName = Request.Cookies["MyCookie"]["username"]; } } protected void Login1_LoggedIn(object sender, EventArgs e) { HttpCookie cookie1 = new HttpCookie("MyCookie"); cookie1.Values.Add("username", Login1.UserName); cookie1.Values.Add("password", Login1.Password); cookie1.Expires = DateTime.Now.AddDays(1);//cookie Expires HttpContext.Current.Response.AppendCookie(cookie1); } I hope this would be helpful. For more information on this refer to the following links: Overview of Forms Authentication[^] How to implement simple Form Authentication[^]

      John Adams ComponentOne LLC. www.componentone.com

      N 1 Reply Last reply
      0
      • J John Ad

        Hi Rams, Refer to the following code that uses a CheckBox and gives the flexibility to the user to save the username: protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { CheckBox cek = (CheckBox)Login1.FindControl("RememberMe"); if (Request.Cookies["username"] == null Request.Cookies["username"].Value.ToString().Trim() == "") { cek.Checked = false; } else { Login1.UserName = Request.Cookies["username"].Value.ToString(); } } } protected void Login1_LoggingIn(object sender, LoginCancelEventArgs e) { CheckBox cek = (CheckBox)Login1.FindControl("RememberMe"); if (cek.Checked == true) { HttpCookie cookie = new HttpCookie("username"); cookie.Value = Login1.UserName; cookie.Expires = DateTime.Now.AddDays(1);//cookie Expires HttpContext.Current.Response.AppendCookie(cookie); } else { HttpContext.Current.Response.Cookies.Remove("username"); } cek.Checked = false; } //--- another way protected void Page_Load(object sender, EventArgs e) { if (Request.Cookies["MyCookie"] != null) { TextBox pass = (TextBox)Login1.FindControl("Password"); pass.Attributes.Add("value", Request.Cookies["MyCookie"]["password"]); Login1.UserName = Request.Cookies["MyCookie"]["username"]; } } protected void Login1_LoggedIn(object sender, EventArgs e) { HttpCookie cookie1 = new HttpCookie("MyCookie"); cookie1.Values.Add("username", Login1.UserName); cookie1.Values.Add("password", Login1.Password); cookie1.Expires = DateTime.Now.AddDays(1);//cookie Expires HttpContext.Current.Response.AppendCookie(cookie1); } I hope this would be helpful. For more information on this refer to the following links: Overview of Forms Authentication[^] How to implement simple Form Authentication[^]

        John Adams ComponentOne LLC. www.componentone.com

        N Offline
        N Offline
        NetRams
        wrote on last edited by
        #3

        This is good, But I am validating login thru membership provider. My problem is, it will login automatically without asking the user name and password when I choose "RememberMe" option checked. I need login control needs to remember only username using "RememberMe" option and password alwasy user needs to enter. Any luck? - Rams.

        Be simple and Be sample.

        L 1 Reply Last reply
        0
        • N NetRams

          This is good, But I am validating login thru membership provider. My problem is, it will login automatically without asking the user name and password when I choose "RememberMe" option checked. I need login control needs to remember only username using "RememberMe" option and password alwasy user needs to enter. Any luck? - Rams.

          Be simple and Be sample.

          L Offline
          L Offline
          leppie
          wrote on last edited by
          #4

          Add a non-expiring cookie. For more info, go to the ASP.NET forum.

          xacc.ide - now with TabsToSpaces support
          IronScheme - 1.0 alpha 4a out now (29 May 2008)
          ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups