While installing SharePoint, Session State is disabled by default. If you have used session in any farm solutions then you might face this error.

Error:

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.

We can resolved the issue in couple of ways as show:

1. Solution :

We can create a sesssion state database and enable session state service with below PS Script.

Enable-SPSessionStateService -DefaultProvision

OR

Enable-SPSessionStateService -DatabaseName "Session State Database" -DatabaseServer "localhost" -SessionTimeout 120

This example enables a ASP.NET session state on a SharePoint Server farm that uses a custom database name, database server, session time-out of 120 minutes, and Windows credentials (due to the lack of a DatabaseCredentials parameter).

2. Solution:

You can register session state handler module in IIS.

  1. Open Internet Information Services manager.
  2. Move to site where problem occurred.
  3. Open modules list of this site.
  4. Add session state handler like show on the following image (click on it):

You can go either way. There are other ways as well like changing web.config and adding session start module or changing enableSessionState value to true.

Kind Regards!!