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?
{
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?