Search code examples
sitecoresession-statepatchsitecore8

Sitecore config patch update sharedSessionState to mongo


Trying to apply the configuration patch to update the shared session state to use mongo per doco below: https://doc.sitecore.net/sitecore_experience_platform/setting_up__maintaining/xdb/session_state/walkthrough_configuring_a_shared_session_state_database_using_the_mongodb_provider

However bit stuck with best way to patch it. One option is to delete the sharedSessionState node and add the mongo settings.

Any help will be good.


Solution

  • You don't need to remove existing <sharedSessionState> node. Just use the patch below:

    <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
      <sitecore>
        <tracking>
          <sharedSessionState>
            <patch:attribute name="defaultProvider">mongo</patch:attribute>
            <providers>
                 <add
                     name="mongo"
                     type="Sitecore.SessionProvider.MongoDB.MongoSessionStateProvider,
                     Sitecore.SessionProvider.MongoDB"
                     connectionStringName="session"
                     pollingInterval="2"
                     compression="true"
                     sessionType="shared"/>
            </providers>
          </sharedSessionState>
        </tracking>
      </sitecore>
    </configuration>
    

    Just remember to add it after Sitecore.Analytics.Tracking.config file.