首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >cookies在大约一分钟后超时,即使我将它设置为60分钟。

cookies在大约一分钟后超时,即使我将它设置为60分钟。
EN

Stack Overflow用户
提问于 2014-01-14 13:43:53
回答 1查看 509关注 0票数 0

我读过一些帖子,我不知道是不是遗漏了什么,但我的cookie很快就停了下来。

这就是我在我的web.config中设置的:

代码语言:javascript
复制
<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=152368
  -->
<configuration>

  <appSettings>
    <add key="webpages:Version" value="1.0.0.0"/>
    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
    <add key="suburbanServiceUrl" value=""/>

  </appSettings>

  <system.web>

    <sessionState
      mode="InProc"
      cookieless="false"
      timeout="60"
    />

    <customErrors mode="Off"/>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      </assemblies>
    </compilation>
    <authentication mode="Forms">
      <!-- timeout: Gets and sets the amount of time, in minutes, allowed between requests
                    before the session-state provider terminates the session. -->
      <forms loginUrl="~/Account/LogOn" timeout="60"/>
    </authentication>

    <membership>
      <providers>
        <clear/>
        <add name="AspNetSqlMembershipProvider"
             type="System.Web.Security.SqlMembershipProvider"
             connectionStringName="ApplicationServices"
             enablePasswordRetrieval="false"
             enablePasswordReset="true"
             requiresQuestionAndAnswer="false"
             requiresUniqueEmail="false"
             maxInvalidPasswordAttempts="30"
             minRequiredPasswordLength="6"
             minRequiredNonalphanumericCharacters="0"
             passwordAttemptWindow="10"
             applicationName="webportal"/>
      </providers>

    </membership>

    <profile>
      <providers>
        <clear/>
        <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="webportal"/>
      </providers>
    </profile>

    <roleManager enabled="true">
      <providers>
        <clear/>
        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="webportal"/>
        <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="webportal"/>
      </providers>
    </roleManager>

    <pages enableSessionState="true">
      <namespaces>
        <add namespace="System.Web.Helpers"/>
        <add namespace="System.Web.Mvc"/>
        <add namespace="System.Web.Mvc.Ajax"/>
        <add namespace="System.Web.Mvc.Html"/>
        <add namespace="System.Web.Routing"/>
        <add namespace="System.Web.WebPages"/>
      </namespaces>
    </pages>
  </system.web>

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="Session"/>
      <add name="Session" type="System.Web.SessionState.SessionStateModule"/>
    </modules>
    <httpProtocol>
    </httpProtocol>
    <staticContent>
      <clientCache cacheControlCustom="public"
      cacheControlMaxAge="00:00:01" cacheControlMode="UseMaxAge" />
    </staticContent>   
  </system.webServer>

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

</configuration>

我取出了连接字符串和服务模型。

在IIS中,我有以下设置:

我相信我的一切都安排在60分钟,但绝对不会持续那么久。

有人看到我错过了什么吗?

编辑

对不起,我在处理超时问题时,出于习惯,在这里包含了会话信息。不管怎么说,正如我告诉西蒙·哈尔西:

我指的是会员饼干。我会在一分钟左右后被送回登录。我已经对我调用的方法进行了授权,这些方法使我在不活动几分钟后返回登录屏幕。

EN

回答 1

Stack Overflow用户

发布于 2014-01-14 14:13:28

哪个饼干要过期了?据我所见,您有两个成员cookie & session cookie。

您的会话cookie是一个浏览器会话cookie,因此它没有设置到期时间-它只存在于浏览器打开时。关闭浏览器时,会话cookie就会消失。会话超时是指会话状态在服务器上的生存期。当您关闭浏览器时,会话将继续运行,直到达到超时为止。由于关闭了浏览器,相应的会话cookie被销毁,因此无法返回该会话。您可以劫持cookie并从另一个浏览器中呈现它&这将扩展会话。

如果您更改了某些内容,如配置文件,则会导致应用程序重新启动&这将杀死所有活动会话。

成员cookie以类似的方式工作。它们也是浏览器会话cookie,除非您在用户登录时持久化cookie。成员曲奇包含一个表单auth票据,其中也有一个到期时间。这一次应该会延长每次你访问该网站,只要它是在规定的时间限制的票。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21115059

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档