I need someone to get forms authentication working on asp.net site (most done)
- or -
Post a project like this3357
£50(approx. $62)
- Posted:
- Proposals: 0
- Remote
- #660484
- Awarded
Description
Experience Level: Intermediate
Estimated project 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:
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:
William D.
97% (6)Projects Completed
8
Freelancers worked with
7
Projects awarded
67%
Last project
2 Mar 2015
United Kingdom
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies