title: flask session list not working
body: <p>I have problems updating a list in a flask session.</p>
  
  <p>I have read the docs (<a href="http://flask.pocoo.org/docs/0.11/api/#sessions" rel="nofollow noreferrer">http://flask.pocoo.org/docs/0.11/api/#sessions</a>) and some answers like this one <a href="https://stackoverflow.com/questions/32713380/how-to-change-values-in-flask-session-dictionary-using-forms">How to change values in Flask session dictionary using forms?</a> and I use the <code>session.modified = True</code> after append, but still getting <code>ReferenceError: weakly-referenced object no longer exists</code></p>
  
  <p>Here is my code:</p>
  
  <pre><code>@s_cart.route("/cart")
  def shopping_cart():
      if "cart" not in session:
          print("There is nothing in your cart.")
          return render_template("cart.html", lista={}, total=0)
      else:
          items = session["cart"]
          cosas = {}
          print(items)
          total_price = 0
          for item in items:
              cassette = aux_methods.get_cassette(item)
              total_price += cassette.price
              if cassette.id in cosas:
                  cosas[cassette.id]["qty"] += 1
              else:
                  cosas[cassette.id] = {"qty": 1, "name": cassette.title, "price": cassette.price}
  
      return render_template("cart.html", lista=cosas, total=total_price)
  
  
  @s_cart.route("/add_to_cart/&lt;_id&gt;")
  def add_to_cart(_id):
      if "cart" not in session:
          session["cart"] = []
  
      session["cart"].append(_id)
      session.modified = True
  
      return redirect("/cart")
  </code></pre>
  
  <p>and I can't find the error.  Any ideas?</p>