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
You can use either MongoDB or SQL Server as your private session state store. SQL Server might be an appropriate option if you are running the collection database (MongoDB) in the cloud as a service, or if you prefer not to run an on-premise MongoDB server instance.
This walkthrough describes how to use a MongoDB database as your private session state store using the Sitecore ASP.NET Session State Provider for MongoDB:
If you are using a MongoDB session provider, all content delivery servers should use the same provider pointing to the same database.
Before you deploy MongoDB as your session database consider the impact that it will have on performance.
Deploy a MongoDB session database
The Sitecore ASP.NET Session State Provider for MongoDB enables you to use MongoDB as your session state store. The provider supports the
SessionEnd event, which the xDB needs to track website visits.
To deploy a MongoDB session database:
- Install the MongoDB database server version 2.6 or later on a dedicated server using the instructions on the MongoDB website.
- In a suitable XML editor, open the
ConnectionStrings.configfile located here:
<sitename>\Website\App_Configand add the following connection string:
<add name="session" connectionString="mongodb://_mongo_server_name_:_port_number_/_session_database_name_" />
add namevalue can be
sharedsessiondepending on whether you are configuring private or shared session state.
- Configure the connection string so that it points to your session database.
- Save your changes.
To configure Sitecore to use the private session-state provider for MongoDB:
- In your site root folder
web.configfile and locate the
<sessionState mode="InProc" cookieless="false" timeout="20">
- Update the
sessionStatesection to use the MongoDB provider instead of
InProcas shown in the following example. Also, change the
nameattribute value to
<sessionState mode="Custom" customProvider="mongo" cookieless="false" timeout="20">
Adjust session state settings
In Sitecore, when you configure a session state, you have the following configuration options:
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.
If you have configured everything correctly, a session database should appear in your list of MongoDB databases after the first web request.