4
votes

If we want to store sessions in SQL Server, which table stores the sessions?

To implement ASP.NET SQL Server mode session state management, you must modify the element of your application's Web.config file as follows:

1.Set the mode attribute of the element to SQLServer to indicate that session state is stored in SQL Server.

2.Set the sqlConnectionString attribute to specify the connection string for SQL Server. For example:

  sqlConnectionString="data source=MySQLServer;user id=<username>;password=<strongpassword>"

Note The user, , must have permissions to perform this operation on the database.

The modified element should appear as follows:

        <sessionState 
        mode="SQLServer"
        sqlConnectionString="data source=127.0.0.1;user id=<username>;password=<strongpassword>"
        cookieless="false" 
        timeout="20" 
/>

The question is that is there a particular table storing the sessions?

Store session in SQL Server is a vague concept.

Thanks.

3
since I know there isn't such a thing in SQL Server if you want handle this make your own table and handle the session for your own. | I can be wrong:)Harry89pl

3 Answers

5
votes

You're supposed to run the ASP.Net SQL Server Registration Tool first. The tool will create the appropriate session state tables.

3
votes

To use SQLServer mode, you must first be sure the ASP.NET session state database is installed on SQL Server. You can install the ASP.NET session state database using the Aspnet_regsql.exe tool. Aspnet_regsql.exe is located at %windir%\Microsoft.NET\Framework\v4.0.30319 ( 32 bit systems .net framework 4 )

Follow the following link to see how to add session table How To configure SQL server to store session state

1
votes

The other answers are correct in that you should use the Aspnet_regsql.exe tool to create the session database for you. But out of interest, once that is done, you can find all sessions stored in the temp sessions table.

For instance, my session database is called ASPState and the table of interest is called ASPStateTempSessions. ASP.NET calls the stored procedures to manage the sessions in this table.