Diesel Posted April 4, 2005 Posted April 4, 2005 protected void dosignin(object sender, EventArgs e) { Session.Abandon(); if (VerifyPassword(accountEmail.Value, password.Value)) { //FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(accountEmail.Value, false, 5000); FormsAuthenticationTicket tkt; string cookiestr; HttpCookie ck; tkt = new FormsAuthenticationTicket(1, accountEmail.Value, DateTime.Now, DateTime.Now.AddMinutes(30), remember.Checked, ""); cookiestr = FormsAuthentication.Encrypt(tkt); ck = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr); if (remember.Checked) ck.Expires=tkt.Expiration; ck.Path = FormsAuthentication.FormsCookiePath; Response.Cookies.Add(ck); string strRedirect; strRedirect = Request["ReturnUrl"]; if (strRedirect==null) strRedirect = "http://test.goecpc.com/main/home.aspx"; Response.Redirect(strRedirect, true); //FormsAuthentication.RedirectFromLoginPage(accountEmail.Value, remember.Checked); } else { //wrong username and/or password errorMsg.Text = "Wrong Username and/or password"; } } I've tried loggin both ways, using FormsAuthentication.RedirectFromLoginPage and creating a cookie manually. Neither have worked. Here's the relevant part of web.config <authentication mode="Forms"> <forms name="mycookie" path="http://abc.com" loginUrl="signin.aspx" protection="All" timeout="30" /> </authentication> Verification of the Username and Password works fine. It redirects to the page it's supposed to. It just doesn't recognize the user being 'logged in'. There is never a value saved to Page.User.Identity.Name. What's the problem? Quote
HJB417 Posted April 5, 2005 Posted April 5, 2005 try removing the code that creates the cookie because the forms authentication module does this for you. Quote
Diesel Posted April 5, 2005 Author Posted April 5, 2005 I've tried loggin both ways, using FormsAuthentication.RedirectFromLoginPage and creating a cookie manually. Neither have worked. Quote
kahlua001 Posted April 6, 2005 Posted April 6, 2005 Some ideas. 1.Session.Abandon(); - Prolly has nothign to do with your ability to create a cookie after you've deleted asp.net'd id cookie, maybe try taking that out, see what happens. 2. How about creating a cookie without using FormsAuthentication.FormsCookieName as the name, see if it gets created. 3. Is remember.Checked returning true. Quote
Diesel Posted April 6, 2005 Author Posted April 6, 2005 I've tried it without session.abandon, doesn't work. I'll try it under a different name. And the last parameter (remember.checked) is to specify a persistant cookie, so it should be created either way. Quote
kahlua001 Posted April 6, 2005 Posted April 6, 2005 if (remember.Checked) If it returns false, then your cookie is not written right. Quote
Administrators PlausiblyDamp Posted April 7, 2005 Administrators Posted April 7, 2005 What is the website URL? Have you tried removing the path attribute from the forms element? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Diesel Posted April 8, 2005 Author Posted April 8, 2005 If anyone wants to know, the problem was that I was using the Response object to read the cookie, whereas I was supposed to be using the Request object. :( Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.