title: Session State ArrayList in Shopping Cart ASP.NET
body: <p>I'm creating a shopping cart application and I'm having some issues with implementing a session state for my arraylist. </p>
  
  <p>in my page load i declared </p>
  
  <pre><code> if (Session["Cart"] == null)
          {
              Session["Cart"] = new ArrayList();
          }
  
          else
          { 
              ArrayList cart = (ArrayList)Session["Cart"];
          }
  </code></pre>
  
  <p>to create the session if it doesn't exist yet. 
  then i have an event handler for a button to add items to the arraylist</p>
  
  <pre><code>protected void onClick_AddBooking(object sender, EventArgs e)
      {
          int ClassID = Convert.ToInt32(Request.QueryString.Get("Class_Id"));
          ArrayList cart1 = new ArrayList();
  
          cart1 = Session["Cart"];       
  
          cart1.Add(ClassID);
  </code></pre>
  
  <p>i'm guessing i just don't know how to handle session states yet, thus the confusion. 
  I'm essentially storing the class_ID then when the student confirms i'll store that to the DB and associate that ID with the Class Details. </p>
  
  <p>Thanks in advance guys!</p>