title: Session state. How to manage session with custom mode?
body: <p>I am working on a website and this is my first web project. </p>
  
  <p>Scenario for Session</p>
  
  <p>I have created a database for my project with security level little bit high. I want to manage session for each and every user who is logging in to my website. Session state can be used using Cookie as well as URL, only one at a time. </p>
  
  <p>Now I went over with all four session state modes.
  i.e
  1. InProc  2. State Server   3. Sql Server   4. Custom</p>
  
  <p>Now after reviewing from all these modes I am in confusion which one should I use Sql Server or Custom.</p>
  
  <p>Basically i want to store session related information in my own database instead of Aspnet_db which is a default database provided by microsoft. I have created all tables related to login and registration. But I dont know how to store session into my database.
  What tables do I need to create so as to maintain into database.</p>
  
  <p>I want to create a complete log of session and login related information into my database(Persistant atleast for 1 year).
  I want to use machinekey as AES and SHA1. </p>
  
  <pre><code>&lt;sessionState mode="Custom" cookieless="AutoDetect" timeout="15" regenerateExpiredSessionId="true" stateNetworkTimeout="10" &gt;
      &lt;/sessionState&gt;
      &lt;machineKey decryption="AES" 
                  validation="SHA1"  
                  decryptionKey="7E047D50A7E430181CCAF7E0D1771330D15D8A58AEDB8A1158F97EEF59BEB45D" 
                  validationKey="68B439A210151231F3DBB3F3985E220CFEFC0662196B301B84105807E3AD27B6475DFC8BB546EC69421F38C1204ACFF7914188B5003C1DCF3E903E01A03C8578"/&gt;
  
  &lt;add name="conString" connectionString="Data Source=192.168.1.5; Initial Catalog=dbName; Integrated Security=True;" providerName="System.Data.SqlClient" /&gt;
  </code></pre>
  
  <p>What all things do i need to specify in webconfig ?</p>
  
  <p>My Data Source= 192.168.1.5 
  Database name= db.mdf</p>
  
  <p><strong>What I need to know about</strong> </p>
  
  <ol>
  <li>What tables do i need to add to my
  database to store session related
  information. eg. Session id (Any
  other field is also stored or not),
  Session Time, Session Start Time,
  Session End Time, Session Expire
  Time. I dont know what all things
  are usually taken.</li>
  <li>Do I need to encrypt Session Id
  before storing into database. If Yes</li>
  </ol>
  
  <p>Encryption will be automatic or do i need to write some code to do this other than that I wrote in web config above.</p>
  
  <ol start="3">
  <li>How mode='custom' will be used into
  web config using my database.</li>
  </ol>
  
  <p>in following code</p>
  
  <pre><code>&lt;sessionState mode="Custom" cookieless="AutoDetect" timeout="15" regenerateExpiredSessionId="true" stateNetworkTimeout="10" &gt; 
  &lt;/sessionState&gt; 
  </code></pre>