If you received this error when use session in your custom aspx page deployed to SharePoint:

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 \\ section in the application configuration.

If you add “EnableSessionState=”true” “ to your it should enable it but also you need to modify you web.config

The problem is that by default, Sharepoint does not allow server side code in .aspx pages by default. You need to enable this using PageParserPath. Add the PageParserPath inside of the PageParserPaths node of the web.config file, changing the virtual path to the path you want to enable. Or you can use /Pages/* as the value if they are in the same folder