title: Saving multiple values in a single session variable and then retrieve them
body: <p>I'm working on asp.net mvc3 application. I guess it's described somewhere but a fast search didn't help much and also I get very diverse opinions on using Session variables but still I have a little time to make a decision.</p>
  
  <p>The problem is that I have a razor view where in image gallery images are shown and user that has permissions can delete one or many images. However I can't delete each image at the time the user click the button, instead I have to collect the id's of the images that have been "deleted" from the user (I remove the span tag which holds the image) but the actual deleting is perform by service and I have to pass the service all the data at once. </p>
  
  <p>All this is inside <code>Html.BeginForm</code> so the data is collected on submit and before that I need a way to store those values somehow. Using sessions seems the easiest way by now. I tried something like this :</p>
  
  <pre><code>public void DeletePicture(long documentImageID)
          {
              if (documentImageID != null)
              {
                  Session["imagesIdForDeleting"] = documentImageID;
              }
          }
  </code></pre>
  
  <p>But with a simple debug I can not figure out first - how at all I can access the <code>documentImageID</code> value from the <code>Session["imagesIdForDeleting"]</code>. I don't know if it's just matter of syntax or I'm trying to make the things less complicated than they are in real. Also - I'm not sure if making something like this I'm actually saving all the values or I rewrite the previous value and always have only one value stored in the session variable. Anyways, Any help how to implement this right would be appreciated.</p>