How to configure session state to use cookies in ASP.NET

Software developer can configure session state through web.config file for his current application (which is found in the same virtual directory as the .aspx web page files).  UseCookies is the one of possible modes for HttpCookieMode. When this mode is set cookies will be always used, even if the browser or device do not support them or they are disabled. This is mode is by default. If the device does not support cookies, session information will be lost over subsequent request, because each request will get a new ID.

<?xml version=”1.0” encoding=”utf-8” ?>
<configuration>
     <system.web>
     <!— other settings are omitted. —>
     <sessionState
        cookieless=”UseCookies” cookieName=”ASP.NET_SessionID”
        regenerateExpiredSessionID=”false”
        timeout=”20”
        mode=”InProc”
        stateConnectionString=”tcpip=127.0.0.1:42424”
        stateNetworkTimeout=”10”
        sqlConnectionString=”data source=127.0.0.1;Integrated Security=SSPI”
        sqlCommandTimeout=”30” allowCustomSqlDatabase=”false”
        customProvider=””
/>
</system.web>
</configuration>