django and internet explorer session loss
<p>I have been trying to find a fix for this all day but no luck.</p>

<p>I have a Django 1.9.4 website that works for all major browsers except for IE.</p>

<p>I am using eclipse to run the Django site locally for testing.</p>

<p>When I log into my site with IE-11 on the local server, it works just fine.</p>

<p>When I pull the site onto a production unit (different IP address, over a network), IE seems to lose the session and I am just in an infinite loop on the login page.</p>

<p>Below are the two functions that I believe are in context to this issue.
"return redirect("myapp:homepage")" goes to a view that is decorated with "@checkLogin"</p>

<p>applylogin gets run and when monitoring the network with IE dev tools under cookies I see the following</p>

<p>Direction   Key Value   Expires Domain  Path    Secure  HTTP only</p>

<p>Received    sessionid   pk5svspepe9xk3og6ctnrwqrc56ukgrh    Mon, 29-Aug-2016 15:39:03 GMT       /   No  Yes</p>

<p>so it appears to have received a session id.</p>

<pre><code>@requires_csrf_token
def applylogin(request):
newUsername = ""
password = ""
err_username = False
err_pass=False
if(request.POST.has_key('username')):
    newUsername=request.POST['username']
if(request.POST.has_key('password')):
    password=request.POST['password']
try:
    user = User.objects.get(username=newUsername)
    if(user.check_password(password)):
        request.session['login'] = newUsername
        request.session['userid'] = user.id
        request.session['useraccess'] = user.access 
        if user.access &gt;= 255:
            request.session['admin'] = True
        else:
            request.session['admin'] = False
        return redirect("myapp:homepage")
    else:
        err_pass=True
except User.DoesNotExist as e:
    err_username=True
    logger.exception(e)
except Exception as e:
    logger.exception(e)
build = getBuildType()
return render(request, "Redacted")


def checkLogin(fn):
def wrapped(request, *param, **dparam):
    str_redirect = ""
    str_loc = dparam.get('location', "xxxx")
    if(str_loc == "xxxx"):
        str_redirect = "xxxx:landingpage"
    else:
        str_redirect = str_loc+":login"

    loginname = request.session.get("login", "")
    try:
        if loginname == "":
            return redirect(str_redirect)
        User.objects.get(username=loginname)
    except User.DoesNotExist:
        return redirect(str_redirect)
    return fn(request, *param, **dparam)
return wrapped
</code></pre>

<p>Also, I am unsure if this has anything to do with the issue but I get this message in my log file only when accessing the site with IE</p>

<pre><code>&gt; Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/sync.py", line 66, in run_for_one
    self.accept(listener)
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/sync.py", line 27, in accept
    client, addr = listener.accept()
  File "/usr/lib/python2.7/socket.py", line 202, in accept
    sock, addr = self._sock.accept()
error: [Errno 11] Resource temporarily unavailable
</code></pre>

<p>I am at a loss right now.
I do not know if it is a Django issue or purely an IE issue.</p>

<p>p.s. I have tried the p3p stuff but that didn't seem to work.</p>

<p>The problem lies in the timezone difference and the cookie expiry.</p>

<p>To test it, I set the SESSION_COOKIE_AGE = 37200 (2hours + 30000seconds) and IE loaded the site just fine.</p>

<p>Interesting that chrome and firefox do not have an issue with this.</p>

python django internet-explorer session gunicorn