Login Problem

Diesel

Contributor
Joined
Aug 18, 2003
Messages
662
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?
 
I've tried loggin both ways, using FormsAuthentication.RedirectFromLoginPage and creating a cookie manually. Neither have worked.
 
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.
 
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.
 
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. :(
 
Back
Top