Mohamad1362
پنج شنبه 09 آذر 1391, 10:02 صبح
من یه مشکلی با Cookie ورود به سایت پیدا کردم ، همه چی داره خوب کار میکنه فقط مشکل اینجاست که وقتی Session منقضی میشه کوکی ورود هم به همراهش منقضی میشه . حتی وقتی کاربر تیک "مرا به خاطر بسپار" رو زده باشه بازم کاربر رو خارج میکنه. این کده منه ، ببینید مشکل کار من کجاست :
if (remembermechkbox.Checked)
{
FormsAuthenticationTicket AuthenticationTicket = new FormsAuthenticationTicket(1, userNametxt.Text.Trim().ToLower(), DateTime.Now, DateTime.Now.AddMinutes(1000), true, "admin");
string encryptedTicket = FormsAuthentication.Encrypt(AuthenticationTicket);
HttpCookie AuthCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
Response.Cookies.Add(AuthCookie);
}
اینم کد Web.Config :
<authentication mode="Forms">
<forms name="SiteCookie" loginUrl="Login.aspx" protection="All" slidingExpiration="true" timeout="1">
</forms>
</authentication>
if (remembermechkbox.Checked)
{
FormsAuthenticationTicket AuthenticationTicket = new FormsAuthenticationTicket(1, userNametxt.Text.Trim().ToLower(), DateTime.Now, DateTime.Now.AddMinutes(1000), true, "admin");
string encryptedTicket = FormsAuthentication.Encrypt(AuthenticationTicket);
HttpCookie AuthCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
Response.Cookies.Add(AuthCookie);
}
اینم کد Web.Config :
<authentication mode="Forms">
<forms name="SiteCookie" loginUrl="Login.aspx" protection="All" slidingExpiration="true" timeout="1">
</forms>
</authentication>