Walkthrough: Configuring a private session state database using SQL

Current version: 8.2

In private session state, the session state database collects and saves all data related to a specific interaction, such as viewed pages, converted goals, triggered campagns, or accumulated engagement points.

This topic outlines how to configure a SQL Server database as your private session state store using the Sitecore ASP.NET Session State Provider for SQL Server.

The SQL Server provider supports the session-end event that is required by the xDB in order to track website visits.

Deploy a SQL Server session database

The Sitecore ASP.NET Session State Provider for SQL Server enables you to use SQL Server as your session state store. This provider supports the SessionEnd event that the xDB needs to track website visits.


You can store shared and private session state info in the same database. The database is able to distinguish between the types of session.

To deploy the SQL Server session database you must:

  1. Start Microsoft SQL Server Management Studio 2012 or later.

  2. Connect to the server node that you want to install the Session database on.

  3. Expand the server node, right-click Databases, and then click Attach.

  4. In the Attach Databases dialog box, click Add .

  5. Browse to the Databases folder in your website root folder, select the Sitecore.Sessions.mdf database and click OK.

  6. In the Attach Databases dialog box, click OK. The session database now appears in your list of attached databases.

  7. Add the following connection string to the ConnectionStrings.config file:

    <add name="session" connectionString="user
            Source=_sqlserver_;Database = _session_database_name_"/>

Optimize SQL Server performance

For each web request, Sitecore accesses the session-state store database multiple times. This can have a significant impact on the performance of your website. Therefore, you should install enough RAM to allow Microsoft SQL Server to keep the session state database in memory. You should also put the database files on an SSD drive.

To achieve optimal performance, you can install an extension to the Sessions database.

To install the performance enhancements:

  1. In Microsoft SQL Server Management Studio, open the Sessions db performance boost.sqlfile. This file is stored in the \Databases\Scripts folder of your Sitecore installation.

  2. In the first line of the Sessions db performance boost.sql file, replace USE [Sitecore_Sessions] with the name of your session database.

  3. In the line EXECUTE [Sitecore_Sessions].[dbo].[CreateTables], replace [Sitecore_Sessions] with the name of your session database.

  4. After you have updated the statements to point to your session database, press F5 to execute the file.


These performance enhancements move the session-state store to SQL Server tempDB which is the standard practice recommended by Microsoft. Every user must have access to tempDB. However, every time SQL Server is restarted, it recreates tempDB and resets the access rights. For information about how to ensure that users always have access to tempDB, see this KB article. For more information see Session-State Modes on MSDN.


The tempdb system database is currently not supported by Azure SQL Database service.

Configure Sitecore

To configure Sitecore to use the private session state provider for SQL Server:

  1. In your site root folder, open the web.config file and locate the sessionState line:

     <sessionState mode="InProc" cookieless="false" timeout="20" 

    Change this line to:

    <sessionState mode="Custom"
        customProvider="mssql" cookieless="false"
  2. Update the sessionState section by adding the SQL Server provider as shown in the following example. Change the name attribute value to mssql:

    <sessionState mode="Custom" customProvider="mssql" cookieless="false" timeout="20">
        <add name="mssql" 

Adjust private session state settings

When you configure a session state, you have the following configuration options in the web.config file:





Contains the connection string that Sitecore uses to connect to the session database.

Edit to specify the session state database that you want to use. In the xDB, this database is called session.


Specifies the time interval in seconds that the session-state provider uses to check if any sessions have expired.


Indicates that you want session-state data to be compressed.

The default value is true. Compressing session state data reduces the amount of data that you need to transfer between the database and the Sitecore instance. This may cause some additional CPU overhead.


Indicates whether the type of session state is private or shared.


Do you have some feedback for us?

If you have suggestions for improving this article,