I need someone to get forms authentication working on asp.net site (most done)

  • Posted:
  • Proposals: 0
  • Remote
  • #660484
  • Awarded
  • 1

Description

Experience Level: Intermediate
Estimated Job duration: 1 day or less
General information for the website: Generic
Kind of development: Customization of existing website
Description of requirements/features: Currently have a basic asp.net site set up, registration works and I have set up all code to verify login credentials.. on login. However I cannot work out how to create the secure login cookie and then later access it to get details like if they are logged in, etc.

Literally looking for that last step.

This is what I have tried doing, but its not working for some reason.

if (common.verify(Password.Text, password))
{
if (activated == "N")
{
message = "Account has not been activated.";
}
FormsAuthentication.SetAuthCookie(Convert.ToString(userId), false);

FormsAuthenticationTicket ticket1 =
new FormsAuthenticationTicket(
1, // version
Convert.ToString(userId), // get username from the form
DateTime.Now, // issue time is now
DateTime.Now.AddHours(12), // expires in 10 minutes
false,
"user"// cookie is not persistent
);
HttpCookie cookie1 = new HttpCookie(
FormsAuthentication.FormsCookieName,
FormsAuthentication.Encrypt(ticket1));
Response.Cookies.Add(cookie1);

FormsAuthentication.RedirectFromLoginPage(Email.Text, true);
}


However I can't later access it via

YouAre.Text = User.Identity.Name;

Thats pretty much all I need to get working, as well as possibly showing how to do things like extend duration of cookie, etc.

New to ASP.NET, but not webdev - hence need for this.
Extra notes:

New Proposal

Create an account now and send a proposal now to get this job.

Sign up

Clarification Board Ask a Question

    There are no clarification messages.