Question: I configured session state in web.config.

```
<sessionState cookieless="AutoDetect" timeout="5" sqlConnectionString="....."/>

```

Now, I want to know timeout and sqlConnectionString from code-behind. Please, help me.

Answer: 
You can use [Session.Timeout](http://msdn.microsoft.com/en-us/library/system.web.sessionstate.httpsessionstate.timeout.aspx) to know timeout value.

However, better way is to use configuration API to read configuration. In this case, use code given below to get reference to [session state configuration](http://msdn.microsoft.com/en-us/library/system.web.configuration.sessionstatesection.aspx) and then use properties such as [SqlConnectionString](http://msdn.microsoft.com/en-us/library/system.web.configuration.sessionstatesection.sqlconnectionstring.aspx) and [Timeout](http://msdn.microsoft.com/en-us/library/system.web.configuration.sessionstatesection.timeout.aspx) to find the necessary configured values.

```
using System.Web.Configuration;

...

var sessionSection = (SessionStateSection)WebConfigurationManager.GetSection("system.web/sessionState");

```
You can use this code 

```
Configuration config = WebConfigurationManager.OpenWebConfiguration("~/Web.config");
SessionStateSection section = (SessionStateSection)config.GetSection("system.web/sessionState");

```