Changing the default value of session's variable timeout in asp.net mvc

So how can i set the timeout of the session's variable unlimited until it is changed by program?Any suggestions?

You can't set timeout value to unlimited.

You can increase the time out value in minutes using the timeout attribute of sessionState element in web.config.


SESSION STATE SETTINGS

By default ASP.NET uses cookies to identify which requests belong to a particular session. If cookies are not available, a session can be tracked by adding a session identifier to the URL. To disable cookies, set sessionState cookieless="true". (120 = minutes)

<sessionState mode="StateServer" cookieless="false" timeout="120"/>

Check out this Session-Time out


You cannot assign it to unlimited. You can increase the value in minutes using the time out attribute of Session state element in web.config

<sessionState timeout="30">
</sessionState>

By default session timeout value is 20 minutes. Also in your case if you are using forms authentication, check the authentication time out value as well

<authentication mode="Forms">
   <forms loginUrl="logon.aspx" 
   protection="All" path="/" timeout="30" />
</authentication>  

It's timeout of the session, not the variable. Set it in configuration in minutes

<sessionState timeout="30" />