title: Django session values occasionally not persisted
body: <p>I have the following REST method that update the value of the session every time a jQuery tab is clicked to store the active tab.</p>
  
  <pre><code>@csrf_exempt
  def update_active_tab_request(request):
      """
      Stores the active tab for a given tab item
      """
      for tab, active in request.GET.iteritems():
          request.session[tab] = int(active)
  
      return HttpResponse("OK", status=200)
  </code></pre>
  
  <p>It's a fairly simple routine, and the issue I'm having is that it that the value is not always stored in the session. I have viewed the web server logs, and I've sprinkled logging statements to verify that the code is being called. Everything appears to be working, but I've found that there is a chance that the session has not been updated when this method returns.</p>
  
  <p>Thinking that it could be a performance/synchronization issue with updating the session, I've changed my session storage to <code>SESSION_ENGINE='django.contrib.sessions.backends.cache'</code> .That didn't help. I've also set <code>SESSION_SAVE_EVERY_REQUEST=True</code> to always save the session. This too hasn't helped.</p>
  
  <p>I'm at a loss to explain this behaviour. Any help in shedding light on the problem will be much appreciated.</p>