---
title: "Walkthrough: Configuring a shared session state database using the Redis provider"
slug: "walkthrough--configuring-a-shared-session-state-database-using-the-redis-provider"
abstract: "Learn how to use the SQL service provider as your private session state store."
---
# Walkthrough: Configuring a shared session state database using the Redis provider

In a shared session state, all data that can be shared across multiple sessions, for example, the data related to contacts, is collected and saved to the session state database.

A contact can make multiple parallel visits to a website, in which case each visit has its own private session state. However, some data can be shared between visits, such as contact related information.

Information that is shared between parallel visits by the same contact is stored in the shared session state store. This data is still private to the contact, but it is accessible from all current sessions made by the same contact.

This walkthrough describes how to use Redis as your out-of-process shared session state store using the Sitecore session state provider for Redis.

This walkthrough describes how to:

- Deploy a shared Redis session database
- Configure Sitecore
- Configure a dedicated Redis Session Processing server
- Adjust the Redis provider settings

> [!note]
> Sitecore does not support Redis Cluster.

<details>
<summary><h2>Deploy a shared session database</h2></summary>

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.

> [!important]
> Do not make changes directly to the configuration files. Instead, you must create a [patch file](https://doc.sitecore.com/xp/en/developers/91/platform-administration-and-architecture/use-a-patch-file-to-customize-the-sitecore-configuration.html "Use a patch file to customize the Sitecore configuration") that performs the required changes during runtime.

To deploy a Redis session database:

1. Choose between Azure Redis or [Redis on premise](https://redis.io/). You can provision Azure Redis by using the instructions on the [Microsoft Azure website](https://azure.microsoft.com/en-us/documentation/articles/cache-dotnet-how-to-use-azure-redis-cache/) or with [Azure PowerShell](https://azure.microsoft.com/en-us/documentation/articles/cache-howto-manage-redis-cache-powershell/).
2. Go to the `<sitename>\Website\App_Config` folder, open the `ConnectionStrings.config` file, and add the following connection string:

    ```text
    <add name="sharedSession" connectionString="_host_:_port_number _" />
    ```

3. Configure the connection string so that it points to your session database.
4. Save your changes.

</details>

<details>
<summary><h2>Configure Sitecore</h2></summary>

The default shared-session store uses the *in process* provider, which stores data in memory and is implemented in the internal ASP.NET class `InProcSessionStateStore`:

```xml
<sharedSessionState defaultProvider="inProc">
  <providers>
    <clear/>
    <add name="inProc"
            type="System.Web.SessionState.InProcSessionStateStore"
            />
  </providers>

```

To configure Sitecore to instead use the shared session state provider for Redis:

1. In your website root folder, go to `App_Config\Sitecore\Marketing.Tracking` folder.
2. Open the `Sitecore.Analytics.Tracking.Config` file.
3. Locate the line where you can define the default shared session state provider using the following path: `sitecore/tracking/sharedSessionState`.
4. Update the `sharedSessionState` section to use *Redis* as the `defaultProvider` (not `inProc` ). You must also, change the name attribute value to `redis`, as shown in the following example:

    ```xml
    <sharedSessionState defaultProvider="redis">
      <providers>
        <clear />
        <add name="redis"
                type="Sitecore.SessionProvider.Redis.RedisSessionStateProvider,
                Sitecore.SessionProvider.Redis"
                connectionString="sharedSession"
                pollingInterval="2"
                applicationName="shared" />
      </providers>
    </sharedSessionState>
    ```

> [!important]
> Do not make changes directly to the configuration files. Instead, you must create a [patch file](https://doc.sitecore.com/xp/en/developers/91/platform-administration-and-architecture/use-a-patch-file-to-customize-the-sitecore-configuration.html "Use a patch file to customize the Sitecore configuration") that performs the required changes during runtime.

</details>

<details>
<summary><h2>Configure a dedicated Expired Session Processing server</h2></summary>

The Sitecore Experience platform supports a dedicated server for processing expired sessions. This means that if you have an environment using a cluster of CD servers, you can use the `pollingEnabled` setting to configure some of the servers to only serve content but not to process the session state data.

With 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).

> [!important]
> The servers that you have dedicated to processing expired sessions must not be for serving content to visitors. For example, if you configure the load balancer for CD servers, you must ensure requests are not being redirected to servers that are dedicated to processing expired sessions.

To enable the `pollingEnabled` setting for a shared session state:

- Go to the `App_Config\Sitecore\Marketing.Tracking\Sitecore.Analytics.Tracking.config` file and ensure the `pollingEnabled` value is set to `true` for your dedicated Expired Processing servers.

To disable expired shared session processing for the CD servers that serve content to visitors:

- Go to the `App_Config\Sitecore\Marketing.Tracking\Sitecore.Analytics.Tracking.config` file and set the `pollingEnabled` value to `false`.

    ```xml
    <sessionState mode="Custom" customProvider="<configured custom provider name>" timeout="20">
      <providers>
        <add name="="<configured custom provider name>"
          …
          pollingEnabled ="false"
          applicationName="shared"/>
      </providers>
    </sessionState>
    ```

</details>

<details>
<summary><h2>Adjust the Redis provider settings</h2></summary>

Use the [Redis provider settings reference](https://doc.sitecore.com/xp/en/developers/91/platform-administration-and-architecture/redis-provider-settings-reference.html "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.

</details>