Platform Administration and Architecture

Configure the expired session cleanup setting

Abstract

How to configure session cleanup setting for your Sitecore Content Delivery role.

The session state provider on the Sitecore Content Delivery role cleans up expired sessions from the session database and stores them in xDB through xConnect. You can configure a setting to minimize the risk of either a bad user experience or losing an expired session.

Minimize the risk of a bad user experience

This is the default setting. You choose this setting to delete the expired session from the session database immediately after the session state provider begins processing it. You risk losing the expired session if it is not successfully submitted to xConnect, but you do not risk delays for the website visitor. To minimize the risk of a bad user experience:

  1. Go to the web.config file in the root folder on the Content Delivery role.

  2. Locate the section named <sessionState> and the child item representing your chosen session provider.

  3. Configure the removeExpiredItemOnlyAfterSessionEndExecution setting to false (the default value), or you can remove the setting entirely.

    <sessionState>
        <providers>
            <add name="redis" removeExpiredItemOnlyAfterSessionEndExecution="false" />
        </providers>
    </sessionState>

Note

Even when the expired session is deleted from the session database, the risk of losing it is very small because it is still stored in the submit queue. An expired session is only really lost if the session expiration processing fails so hard that the session is not stored in the submit queue.

Minimize the risk of losing an expired session

You choose this setting to keep the expired session in a locked state in the session database until the session provider has successfully processed it and submitted it to xConnect. You risk delays for the website visitor, but you do not risk losing the expired session. To minimize the risk of losing an expired session:

  1. Go to the web.config file in the root folder on the Content Delivery role.

  2. Locate the section named <sessionState> and the child item representing your chosen session provider.

  3. Configure the removeExpiredItemOnlyAfterSessionEndExecution to true setting.

    <sessionState>
        <providers>
            <add name="redis" removeExpiredItemOnlyAfterSessionEndExecution="false" />
        </providers>
    </sessionState>

Note

The website visitor only risk experiencing delays, if the visitor was inactive long enough for the session to expire, and the session was locked for expiration processing, and the expiration processing operation for some reason took a long time.