title: MVC 4: How to maintain sessions and cookies to be still valid after IIS restart?
body: <p>It seems that my login session (using simple membership) and cookies (verification token) are not valid after IIS server restart. This is a problem for me, if a user in the middle of a transaction then the server restart, the user has to refill the form and do it again, also it can be some code issue when the transaction is interrupted in the middle of the process.</p>
  
  <p>How to make them to be still valid after server restart?</p>
  
  <p>Here is my web.config:</p>
  
  <pre><code>&lt;membership /&gt;
  ...
  &lt;sessionState mode="InProc" cookieless="false" timeout="2880" /&gt;
  ...
  &lt;authentication mode="Forms"&gt;
    &lt;forms loginUrl="~/Account/Login" timeout="2880" /&gt;
  &lt;/authentication&gt; 
  ...
  &lt;staticContent&gt;
    &lt;clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" /&gt;
    &lt;remove fileExtension=".woff" /&gt;
    &lt;remove fileExtension=".woff2" /&gt;
    &lt;mimeMap fileExtension=".woff" mimeType="application/font-woff" /&gt;
    &lt;mimeMap fileExtension=".woff2" mimeType="application/font-woff2" /&gt;
  &lt;/staticContent&gt;
  </code></pre>
  
  <hr>
  
  <h2>Update</h2>
  
  <p>I tried to use SQLServer to store the session state. Then new problem arise, which I cannot use <code>ViewBag</code> because it is not <code>Serializable</code>. </p>
  
  <p>Is there another way I can achieve this?</p>