Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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".

like image 230
TheFrack Avatar asked Dec 13 '25 05:12

TheFrack


2 Answers

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

like image 92
Claudio Redi Avatar answered Dec 15 '25 17:12

Claudio Redi


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

like image 28
Rushabh Avatar answered Dec 15 '25 17:12

Rushabh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!