Platform Administration and Architecture

Walkthrough: Configuring a private session state database using the Redis provider

Abstract

How to use Redis as your private session state store.

In 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.

Note

Content Management (CM) servers do not support using an external session state database. On CM servers you can only use in process session state.

This walkthrough describes how to use Redis as your private session state store using the Sitecore ASP.NET Session state store provider for Redis. It describes how to:

Note

If you are using a Redis session provider, all content delivery (CD) servers must use the same provider pointing to the same database.

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:

  1. Choose between Azure Redis or Redis on premise. You can provision Azure Redis by using the instructions on the Microsoft Azure website or with Azure PowerShell.

  2. Go to <sitename>\App_Config, open the ConnectionStrings.config file, and add the following connection string:

    <add name="session" connectionString="_host_:_port_number _" />
  3. Configure the connection string so that it points to your session database.

  4. Save your changes.

Configure Sitecore

Note

Do not make changes directly to the configuration files. Instead, you must create a patch file that performs the required changes during run time.Use a patch file to customize the Sitecore configuration

To configure Sitecore to use the private Session state store provider for Redis:

  1. Go to your site root folder, open the web.config file, and locate the sesssionState section:

    <sessionState mode="Inproc" cookieless="false" timeout="20">
  2. Update the sessionState section to use the Redis provider instead of InProc, as shown in the following example. Also, change the name attribute value to redis:

    <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>

Adjust the Redis provider settings

To adjust the provider settings:

If you have configured everything correctly, session records will appear in your Redis session database after the first web request.