Sitecore - Session expires in one minute and how to mitigate this default behavior

  • 1 min read

Intro

So, here's a situation I came across recently where visitor's session would expire within one minute of them being on the Sitecore based site. I had not noticed this strange behavior until we decided to store user-related information into Session and kept seeing it disappear after one minute. Apparently, this is a default behavior in Sitecore v7, 8, and 9 where visitors to the site are treated as bots and their session lasts only one minute. In addition, this behavior also causes issues with xDB tracking so if you are planning on using either one of these features, please continue to read on.

Solution

To mitigate this odd default behavior, it involves modifying your site's layout file to include the following tag in the head element. I simply referenced the Sitecore.Mvc.Analytics.NoReferences NuGet package and used the extension that Sitecore provides.

@using Sitecore.Mvc.Analytics.Extensions

<head>
@Html.Sitecore().VisitorIdentification()
</head>

After adding this tag to the site's layout, the xDB tracking along with Session started working as expected and the Session expiration was set to configured timeout value. I hope this helps!

Additional Resources

You can read more about configuring robot detection functionality in Sitecore on their offical site.