title: Storing a Dictionary to a Session
body: <p>I created this function but it seems to give me a problem. I want to store a dictionary into an Session variable so I can access the dictionary throughout the website. I keep getting the error <strong>Object required: DictionaryObject</strong> or it will say <strong>This key already exist in the dictionary</strong>. Can someone please tell me what I am doing wrong?</p>
  
  <p>I did look <a href="https://stackoverflow.com/questions/4838129/storing-dictionary-in-session">storing dictionary in session</a> at this posting but didn't really fit what I am trying to do!</p>
  
  <pre><code>Function LoadPermissions()
  
      Dim SQLString
      SQLString ="SELECT datafields here... FROM " &amp; TBL_employees_permissions &amp; " AS p WHERE p.eid = '" &amp; Clng(12) &amp; "';"
  
      If IsObject(Session("dicPermissions")) = True Then
          Set dicPermissions = Session("dicPermissions")
      Else
          Set dicPermissions = Server.CreateObject("Scripting.Dictionary")
      End If
  
      db_conn conn, rs '
      Set myRS = conn.Execute (SQLString) 
  
      For each item in myRS.Fields
          If IsObject(Session("dicPermissions")) = True AND DictionaryObject.Exists(Trim(item.Name)) = False Then
              dicPermissions.Add Trim(item.Name), Trim(myRS(item.Name))
          End If
      Next
      db_disconn conn, rs
  
      Set Session("dicPermissions") = dicPermissions 'Store Dictionary to session array.
  
  End Function
  </code></pre>