> For the complete documentation index, see [llms.txt](https://nicholashew.gitbook.io/knowledge/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nicholashew.gitbook.io/knowledge/programming/database/mssql/session-state.md).

# Session State

## Step 1

Update the web.config

* mode: SQLServer
* allowCustomSqlDatabase: true (if create a custom database name)
* sqlConnectionString: server={server};database={database};uid={username};pwd={password}

```markup
<sessionState 
  customProvider="DefaultSessionProvider" 
  mode="SQLServer" 
  allowCustomSqlDatabase="true"
  sqlConnectionString="server=localhost;database=ASPState_Testing;uid=sa;pwd=password">
```

## Step 2

In the MSSQL, created a database named 'ASPState\_Testing' (for this example).

## Step 3

Run 'aspnet\_regsql.exe' using command prompt with following command line

```
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql -d <Databse> -S <Server> -U <Username> -P <Password> -ssadd -sstype c

# Example
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql -d ASPState_Testing -S localhost -U sa -P password -ssadd -sstype c
```
