Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2011-03-15
3
540 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 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