To fix this type of issue, we explicitly set EnableSessionState as True in Web.Config

<%@ Page EnableSessionState="True" %>

And ensure all related individual pages don't set this value as False in page level. After that, the issue still happens, in memory dump, the System.Web.SessionState.InProcSessionState object doesn't appear at all.

Further check the Web.Config in SharePoint web.config, found ASP.NET session module was commented:

For current SharePoint web applications, this is a default behavior that Session object is not accessible because SharePoint application removes the Session Module and set EnableSessionState as False. After add the session module back and set the EnableSessionState as True in Web.Config, the System.NullReferenceException problem got resolved.