開発中の Web サイトにユーザーをログインさせるために、ASP.NET フォーム認証を使用しています。
機能の一部は、ユーザーがチェックすると 1 か月間ユーザーを記憶する「Remember me」チェックボックスです。
ユーザーをログインさせるコードは次のとおりです。
public static void Login(HttpResponse response, string username,
bool rememberMeChecked)
{
FormsAuthentication.Initialize();
FormsAuthenticationTicket tkt = new FormsAuthenticationTicket(1, username, DateTime.Now,
DateTime.Now.AddMinutes(30), rememberMeChecked,
FormsAuthentication.FormsCookiePath);
HttpCookie ck = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(tkt));
ck.Path = FormsAuthentication.FormsCookiePath;
if (rememberMe)
ck.Expires = DateTime.Now.AddMonths(1);
response.Cookies.Add(ck);
}
web.config の関連セクションは次のとおりです。
<authentication mode="Forms">
<forms loginUrl="Home.aspx" defaultUrl="~/" slidingExpiration="true" timeout="43200" />
</authentication>
これにより、ユーザーは問題なくログに記録されますが、サイトを使用しない場合は 30 分後にログアウトされます。ただし、永続性プロパティ (rememberMeChecked) が true に設定されており、true の場合、Cookie は 1 か月後に有効期限が切れるように設定されます。私がここに欠けているものはありますか?
前もってありがとう、F