Login Control in Visual Studio 2005
-
Hi, Please any one explain me in detail how can I make use of "Remember me next time" option for Login Control. Thanks.
-
Hi, Please any one explain me in detail how can I make use of "Remember me next time" option for Login Control. Thanks.
use
Cookies
For ThatBest Regards ----------------- Abhijit Jana "Success is Journey it's not a destination"
-
Hi, Please any one explain me in detail how can I make use of "Remember me next time" option for Login Control. Thanks.
-
use
Cookies
For ThatBest Regards ----------------- Abhijit Jana "Success is Journey it's not a destination"
I have written some code.But its incompleate. Please explain me in detail how to go ahead from here. protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { if (this.Login1.RememberMeSet) { //Check if the browser support cookies if ((Request.Browser.Cookies)) { //Check if the cookie with name PBLOGIN exist on user's machine if ((Request.Cookies["PBLOGIN"] == null)) { //Create a cookie with expiry of 30 days Response.Cookies["PBLOGIN"].Expires = DateTime.Now.AddDays(30); //Write username to the cookie Response.Cookies["PBLOGIN"].Values["UNAME"] = this.Login1.UserName.ToString(); //Write password to the cookie Response.Cookies["PBLOGIN"].Values["UPASS"] = this.Login1.Password.ToString(); } //If the cookie already exist then wirte the user name and password on the cookie else { Response.Cookies["PBLOGIN"].Values["UNAME"] = this.Login1.UserName.ToString(); Response.Cookies["PBLOGIN"].Values["UPASS"] = this.Login1.Password.ToString(); } } } }
-
I have written some code.But its incompleate. Please explain me in detail how to go ahead from here. protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { if (this.Login1.RememberMeSet) { //Check if the browser support cookies if ((Request.Browser.Cookies)) { //Check if the cookie with name PBLOGIN exist on user's machine if ((Request.Cookies["PBLOGIN"] == null)) { //Create a cookie with expiry of 30 days Response.Cookies["PBLOGIN"].Expires = DateTime.Now.AddDays(30); //Write username to the cookie Response.Cookies["PBLOGIN"].Values["UNAME"] = this.Login1.UserName.ToString(); //Write password to the cookie Response.Cookies["PBLOGIN"].Values["UPASS"] = this.Login1.Password.ToString(); } //If the cookie already exist then wirte the user name and password on the cookie else { Response.Cookies["PBLOGIN"].Values["UNAME"] = this.Login1.UserName.ToString(); Response.Cookies["PBLOGIN"].Values["UPASS"] = this.Login1.Password.ToString(); } } } }
// Function to remember the login details in a cookie. function RememberMe() { // Get the login data. var username = document.getElementById('txtUsername').value; var password = document.getElementById('txtPassword').value; // Remember the cookie for 100 days from now. var date = new Date(); date.setTime( date.getTime() + (8640000000) ); // Set the cookie. document.cookie = "Username=" + username + "; expires=" + date.toGMTString() + "; path=/"; document.cookie = "Password=" + password + "; expires=" + date.toGMTString() + "; path=/"; } ' Read and set the username and password from the cookies. If IsNothing(Request.Cookies("Username")) = False Then txtUserName.Text = Request.Cookies("Username").Value If IsNothing(Request.Cookies("Password")) = False Then txtPassword.Text = Request.Cookies("Password").Value
Source : http://www.geekpedia.com/tutorial81_Handling-cookies-in-ASP-.NET.html[^]Best Regards ----------------- Abhijit Jana "Success is Journey it's not a destination"