Session state can only be used when enableSessionState is set to true error in SharePoint 2010

This SharePoint tutorial, we will discuss how to fix error “Session state can only be used when enableSessionState is set to true” which comes in SharePoint 2010.

The full error message which comes as Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the <configuration>\<system.web>\<httpModules> the section in the application configuration.

Session state can only be used when enableSessionState is set to true

Approach-1:
We have to enable session state for the pages by adding enableSessionState=”true” in the page directives.

Then we need to modify in the web.config file like below:

Go to the <modules runAllManagedModulesForAllRequests=”true”>

Remove <remove name=”Session” />

And add the below line:

<add name=”Session” type=”System.Web.SessionState.SessionStateModule” preCondition=”” />

Now Save this and it should work fine.

Approach-2:
Run the below PowerShell command:

Enable-SPSessionStateService –DefaultProvision

You may like following SharePoint tutorials:

I hope this SharePoint 2010 tutorial helps to solve Session state can only be used when enableSessionState is set to true error which comes in SharePoint 2010.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

>