views:

272

answers:

1

I'm using Django+Appengine on a page that has both a normal HTML request to get the page, and an AJAX request using jQuery. On normal requests, it loads the current user and session information just fine. However, for the AJAX requests, self.user isn't set and users.get_current_user() doesn't return anything.

Both handlers are on the same domain, and even in the same .py file. Using WING IDE to debug, the only difference between the two is that in the normal request, webob._parsed_cookies is set to the session id, and in the AJAX request it isn't set at all. Although, both show the same session id in request._environ.HTTP_COOKIE.

This makes me think something about it being an AJAX request rather than an HTML request is keeping GAE from knowing to load session information. Ideas?

Edit: Sorry this was my fault. I didn't realize I was using a custom user implementation of users to make it more like django rather than google users - and I had skipped a step that involved manually getting the session id out of the cookies and looking up the active user corresponding to that session id and setting it as the 'user' instance variable for the request. That is why the session id was in the request but the user object wasn't set.

  1. List item
A: 

You certainly need to have session id set in cookies, because this is how django determines, which user is logged. You have to post some of your jquery code and corresponding view, to try to guess, what's going wrong.

gruszczy