Django can use session I set, but can not see that in web browser's inspector
I'm using `Django` with `MongoDB` as a back-end database.

In `settings.py` I already set these codes:

    SESSION_ENGINE = 'mongoengine.django.sessions'

    'django.contrib.sessions.middleware.SessionMiddleware',

    'django.contrib.sessions',

And in my `view/user.py` (only part of the code)

                     if user.password == password:
                        #add session information
                        if request.session.test_cookie_worked():
                            returnmsg = "COOKIE OK"
                        else:
                            returnmsg = "COOKIE ERR"
                        response = HttpResponse(returnmsg)
                        response.set_cookie("username", username)
                        request.session['username'] = username
                        user.log.append(UserLog(time=datetime.now(), ip=request.META['REMOTE_ADDR'], login=True))
                        user.save()
                        return response

When I run my site, I could login by this function and other functions which need verify my session setting could read `username` from `response.session`.

But the returnmsg is `COOKIE ERR`, and when I use Web Inspector of Safari, I can see no session or cookie here.

Where does Django store it session data? Should it be an encoded cookie on client's computer? If it does not store on my client's computer, why `Django` still could get that?
And in my code I also tried just set a cookie directly, it still does not work.

Is there something wrong about `MongoEngine`? Did I use it in the wrong way?
Django can use session I set, but can not see that in web browser's inspector
===

I'm using `Django` with `MongoDB` as a back-end database.

In `settings.py` I already set these codes:

    SESSION_ENGINE = 'mongoengine.django.sessions'

    'django.contrib.sessions.middleware.SessionMiddleware',

    'django.contrib.sessions',

And in my `view/user.py` (only part of the code)

                     if user.password == password:
                        #add session information
                        if request.session.test_cookie_worked():
                            returnmsg = "COOKIE OK"
                        else:
                            returnmsg = "COOKIE ERR"
                        response = HttpResponse(returnmsg)
                        response.set_cookie("username", username)
                        request.session['username'] = username
                        user.log.append(UserLog(time=datetime.now(), ip=request.META['REMOTE_ADDR'], login=True))
                        user.save()
                        return response

When I run my site, I could login by this function and other functions which need verify my session setting could read `username` from `response.session`.

But the returnmsg is `COOKIE ERR`, and when I use Web Inspector of Safari, I can see no session or cookie here.

Where does Django store it session data? Should it be an encoded cookie on client's computer? If it does not store on my client's computer, why `Django` still could get that?
And in my code I also tried just set a cookie directly, it still does not work.

Is there something wrong about `MongoEngine`? Did I use it in the wrong way?