Solved

ASP.net 2.0, create Persistant Cookie via code for Login  'Remember me'

Posted on 2011-03-15
3
531 Views
Last Modified: 2012-05-11
Hi,
I am trying to develop a login page for my website using Login control.
I am not using any Membership(webconfig) to validate the user.

Infact , i am overwriting the OnAuthenticate method of the Login control and Authenticating the user succesfully.

Now, inorder to use the functionality of "Remember me"  check box, How i create the persistant cokkie when ever user selects the "Remember me".
pls advice me ...

Pls Note:- i'm not using any Membership. User details are stored in AD... and im using LDAP to Authenticate ----using ASP.net 2.0,C#
0
Comment
Question by:kishan66
  • 3
3 Comments
 

Author Comment

by:kishan66
ID: 35140267
FYI,

i'm creating a cokkie when the user is Authenticated...

now for "Remember me" , do i have to create another cookie with username & password?
pls give me a sample code for the same
if (Authenticated())
{
   string encryptedTicket = FormsAuthentication.Encrypt(authTicket);
                    HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
                    Response.Cookies.Add(authCookie);
                    Response.Redirect(FormsAuthentication.GetRedirectUrl(txtUserName.Text, false));
}

Open in new window

0
 

Accepted Solution

by:
kishan66 earned 0 total points
ID: 35142791
Thank you for not Responding to my question.

I figured it out by using Cookies again.
0
 

Author Closing Comment

by:kishan66
ID: 35142815
(May be not the best Solution) but works.
once Authenticated check for if(Login1.RememberMe) true...then
create cookie for UserName & Password and add it to response object.
 Response.Cookies.Add(aCookie);
In the page load ()
 if (Request.Cookies["user"] != null)
                Login1.UserName = Server.HtmlEncode(Request.Cookies["user"].Value);  

Thats it ...
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now