TheFrack
TheFrack

Reputation: 2873

How to store and access sessions in the database

I'm doing an advanced project with ASP .NET Sessions, I would like to know:

A) What do I add exactly to my web.config to enable full session writing to the database server.

B) What table would the sessions be stored in once enabled? So far I'm only aware that the default is "TempDB".

Upvotes: 3

Views: 6534

Answers (2)

Rushabh
Rushabh

Reputation: 385

Follow the steps mentioned at below link: http://support.microsoft.com/kb/308100

Upvotes: 2

Claudio Redi
Claudio Redi

Reputation: 68440

You can find all configuration details on this MSDN article. Go to section SQL Server Mode

This is the required configuration

<configuration>
  <system.web>
    <sessionState mode="StateServer"
      stateConnectionString="tcpip=SampleStateServer:42424"
      cookieless="false"
      timeout="20"/>
  </system.web>
</configuration>

Here you have some details about where the session information is stored and how to change the default location. For more details, check this article as Andre Calil suggested.

By default, the Aspnet_regsql.exe tool will create a database named ASPState containing stored procedures that support SQLServer mode. Session data itself is stored in the tempdb database by default. You can optionally use the -sstype option to change the storage location of session data

Upvotes: 3

Related Questions