问题描述
在登录表单中,我将Cookie到期时间设置为120分钟。它在我的本地机器上工作。但它不能在Online Hosting Server上运行。但是当我将到期时间设置为15秒或1分钟时,它正在Online Hosting Server上运行。如果我设置很长时间,它只能工作6分钟。在线托管服务器上的cookie过期时间不超过6分钟。我使用Plesk Web Host Edition。我在ASP.NET设置中更改会话超时。但它仍然无法正常工作。我在哪里需要更改设置。我没有在Plesk帮助指南中找到解决方案。
我设置这样的cookie
FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1,checkUser.UserName,DateTime.Now,DateTime.Now.AddMinutes(FormsAuthentication.Timeout.TotalMinutes),true,);
string encTicket = FormsAuthentication.Encrypt(authTicket);
HttpCookie faCookie = new HttpCookie(FormsAuthentication.FormsCookieName,encTicket);
Response.Cookies.Add(faCookie);
在Web配置中,
< authentication mode =Forms >
< forms name =mitfloginUrl =〜/ Account / LogIntimeout =120/>
< sessionstate timeout =120>
In login form, I set cookie expiration to 120 minutes. It's working in my local machine. But It's not working at Online Hosting Server. But when I set expiration to 15 seconds or 1 minutes, it's working at Online Hosting Server. If I set to long time, it's only work for 6 minutes. The cookie expiration is no longer than 6 minutes at Online Hosting Server. I use Plesk Web Host Edition. I change session timeout in ASP.NET Settings. But it's still not working. Where do I need to change setting. I did not found the solution in also Help Guide of Plesk.
I set cookie like this
FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, checkUser.UserName, DateTime.Now, DateTime.Now.AddMinutes(FormsAuthentication.Timeout.TotalMinutes), true, "");
string encTicket = FormsAuthentication.Encrypt(authTicket);
HttpCookie faCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
Response.Cookies.Add(faCookie);
In Web Config,
<authentication mode="Forms">
<forms name="mitf" loginUrl="~/Account/LogIn" timeout="120" />
<sessionstate timeout="120">
Can anyone help me please...
推荐答案
这篇关于Cookie过期在线托管不超过6分钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!