Walkthrough: Configuring a private session state database using the Redis provider
Learn how to use Redis as your private session state store.
In a private session state, all data related to a specific interaction, such as viewed pages, converted goals, triggered campaigns, or accumulated engagement points, is collected and saved to the session state database.
This walkthrough describes how to use Redis as your private session state store using the Sitecore ASP.NET Session state store provider for Redis.
Sitecore does not support Redis Cluster.
To prevent unexpected behavior such as data loss, we recommend that you do not enable
aspnet:AllowConcurrentRequestsPerSession. These issues might occur when using this option because the session is not blocked during the request.
Deploy a private Redis session database
The Sitecore ASP.NET Session state store provider for Redis enables you to use Redis as your session state store. The provider supports the
SessionEnd event, which the xDB needs to track website visits.
To deploy a Redis session database:
Go to the
<sitename>\App_Config\folder, open the
ConnectionStrings.configfile, and add the following connection string:RequestResponseshell
<add name="session" connectionString="_host_:_port_number _" />
Configure the connection string so that it points to your session database.
Save your changes.
To configure Sitecore to use the private Session state store provider for Redis:
Go to your site root folder, open the
web.configfile, and locate the
<sessionState mode="InProc" cookieless="false" timeout="20">
sessionStatesection, update the
customProviderattribute to use the
redisprovider instead of
InProc, as shown in the following example. Also, change the value of the
nameattribute value to
<sessionState mode="Custom" customProvider="redis" timeout="20"> <providers> <add name="redis" type="Sitecore.SessionProvider.Redis.RedisSessionStateProvider, Sitecore.SessionProvider.Redis" connectionString="session" pollingInterval="2" applicationName="private"/> </providers> </sessionState>
Configure a dedicated Expired Session Processing server
The Sitecore Experience platform supports a dedicated Redis server. This means that if you have an environment using a cluster of CD servers, you can configure some of the servers to only serve content, but not to process the expired session state data by using the
pollingEnabled setting you can enable/disable expired session processing. For example, you can enable it on the CD servers that are dedicated to processing expired sessions and disable it on the live CD servers (that serve content to visitors).
You must ensure the servers that are dedicated to processing expired sessions are not serving content to visitors. For example, if you have configured a load balancer for CD servers, ensure requests do not redirect to servers that are dedicated to processing expired sessions.
To enable the
pollingEnabled setting for expired private session processing:
Go to the
web.configfile and check the
pollingEnabledvalue is set to
truefor your dedicated Expired Session Processing servers.
To disable expired session state processing for the CD servers that serve content to customers:
Go to the
web.configfile and set the
pollingEnabledvalue to false:RequestResponseshell
<sessionState mode="Custom" customProvider="<configured custom provider name>" timeout="20"> <providers> <add name="="<configured custom provider name>" … pollingEnabled ="false" applicationName="private"/> </providers> </sessionState>
Adjust the Redis provider settings
Use the Redis provider settings reference to configure your session state. If you have configured everything correctly, session records appear in your Redis session database after the first web request.