Cookie过期在线托管不超过6分钟 [英] Cookie Expiration is not more than 6 minutes at online Hosting

查看:100
本文介绍了Cookie过期在线托管不超过6分钟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在登录表单中,我将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持续时间是基于客户端的操作,因此它是非常非常不可能是导致问题的Cookie - 新浏览器可能会忽略cookie过期并提前删除它们,但这种情况不太可能发生,而且主要的四种情况都不会发生。

因此它可能是会话,而不是Cookie。

您需要与您的托管公司交谈:一些(特别是市场上更便宜的一端)将会话限制在比标准20分钟,以最大限度地利用可用资源。如果他们这样做,那么通常无论您尝试设置什么值都无关紧要,任何比新默认值更长的内容都将被忽略。他们可能会为您扩展此功能 - 或者转移到不会缩短持续时间的其他托管公司。
Cookie duration is a client based operation, so it's very, very unlikely that it's Cookies that cause the problem - it's possible that a "new" browser may ignore cookie expiration and deleted them early, but it's very unlikely, and doesn't happen with any on the main four.
So it's probably the Session, rather than Cookies.
You need to talk to your hosting company: some (particularly the cheaper end of the market) restrict the Session to a short interval than the standard 20 minutes, in order to maximise available resources. If they do, then generally it doesn't matter what value you try to set, anything longer than the new default will be ignored. They may be able to extend this for you - or move to a different hosting company which doesn't reduce the duration.


这篇关于Cookie过期在线托管不超过6分钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆