为什么我的httpsessionstate失去了价值?

kru*_*rul 2 sitecore sitecore8

我正在处理Sitecore应用程序,它将一些"项目"存储到购物车中,供未经过身份验证的用户(我猜他们不应该这样)使用如下代码:

 this.Session["abc"] 
Run Code Online (Sandbox Code Playgroud)

然后,一旦用户到达购物车页面并希望继续进行,而不是等待时间超过一分钟而不是会话中的价值丢失!

这是我的web.config相关设置:

我在这里的绳索结束,不知道什么是清洁我的会话?

<sessionState mode="InProc" cookieless="false" timeout="20" sessionIDManagerType="Sitecore.FXM.SessionManagement.ConditionalSessionIdManager">
  <providers>
    <add name="mongo" type="Sitecore.SessionProvider.MongoDB.MongoSessionStateProvider, Sitecore.SessionProvider.MongoDB" sessionType="Standard" connectionStringName="session" pollingInterval="2" compression="true" />
    <add name="mssql" type="Sitecore.SessionProvider.Sql.SqlSessionStateProvider, Sitecore.SessionProvider.Sql" sessionType="Standard" connectionStringName="session" pollingInterval="2" compression="true" />
  </providers>
</sessionState>
Run Code Online (Sandbox Code Playgroud)

<authentication mode="None">
  <forms name=".ASPXAUTH" cookieless="UseCookies" timeout="90" />
</authentication>
Run Code Online (Sandbox Code Playgroud)

我想你不需要通过身份验证来使用会话?是的,我确实检查了代码,确保没有任何东西使我的会话无效.

Mar*_*lak 7

当您没有VisitorIdentification布局时,通常会发生1分钟会话超时的问题.Sitecore将每个新访客视为潜在的爬行机器人,如果没有必要,尽量不要使用20分钟的会话.

确保你VisitorIdentification的布局.您可以像以下那样为Web窗体添加它:

<%@ Import Namespace="Sitecore.Analytics" %>
<sc:VisitorIdentification runat="server" />
Run Code Online (Sandbox Code Playgroud)

对于那样的MVC:

@using Sitecore.Mvc.Analytics.Extensions
@Html.Sitecore().VisitorIdentification()
Run Code Online (Sandbox Code Playgroud)

如果您的Visual Studio仍然抱怨它无法VisitorIdentificationSitecore.Web.UI.WebControls命名空间中找到类型,请检查是否Sitecore.Analytics从您的Web项目中引用了以及是否在以下Sitecore.Analytics位置注册:<system.web><pages><controls>web.config

<add tagPrefix="sc" namespace="Sitecore.Web.UI.WebControls" assembly="Sitecore.Analytics" />
Run Code Online (Sandbox Code Playgroud)

编辑:

考虑为机器人设置数千个会话,并且每个会话在RAM使用方面都非常重要.如果它们全部保留20分钟,它们可以轻松地杀死服务器.这就是Sitecore为每个新用户更改会话超时并将其设置为1分钟的原因.

如果Sitecore布局配置正确并且VisitorIdentification包含,您的浏览器将自动执行对您的服务器的另一个请求,您的会话超时将扩展到默认设置web.config(例如20分钟)