joerussbowman / gaeutilities

gaeutilities - A collection of utilities to help with application development on Google Appengine
http://gaeutilities.appspot.com
BSD 3-Clause "New" or "Revised" License
78 stars 4 forks source link

Session mysteriously stops #4

Open joerussbowman opened 15 years ago

joerussbowman commented 15 years ago

* ticket log from old Google Code site *

What steps will reproduce the problem?

This is oversimplified, but essentially:

  1. In Django Create a session likeso:

from appengine_utilities import sessions

Here is a Django view

def signin(request): request.session = sessions.Session() request.session['person'] = 'identity'

There are other views that access request.session['person'], e.g.:

def do_something(request): return HttpResponse("Person: %s" % request.session['person'])

  1. View a page or two within the next 30 seconds to 2 minutes, and request.session data will be {'person':'identity'}. Sometimes the request.session data lasts for an hour. Other times it disappears after seconds.
  2. Mysteriously request.session becomes {}

What is the expected output? What do you see instead?

I would expect that request.session would not lose its information.

What version of the product are you using? On what operating system?

Please provide any additional information below.

I note that after the session has disappeared _AppEngineUtilities_Session in GAE datastore contains a sid equal to the value of a gaeutilities_session cookie. There is nothing else in the datastore (i.e. no _AppEngineUtilities_SessionData)

I'm afraid I'm just not using gaeutilities sessions properly, but I've tried everything I can think of so I think there is still something amiss, here.

Is there any more information I could provide that may be of assistance?

Thank you.

Delete comment Comment 1 by bowman.joseph, Oct 03 (41 hours ago)

Session, by default, relies on the cookie, ip address, and user agent of the browser to persist. I have seen cases where the local development server, on restart, will lose the session. Is this what is going on, or are you experiencing this on the live server?

You can try turning off user agent checking and ip checking in the settings file to see if that helps. You can also turn the clean check percent to 0, and track your cookies in your browser on each request to see if you can figure out where it's being dropped. The reason you're only seeing one session is it's highly likely any expired session is getting deleted.

Lastly, do you have a lot of AJAX requests going on your page? The 3 token system should be fine with this, but just a thought.

Delete comment Comment 2 by brianmhunt, Yesterday (22 hours ago)

Thank you for the response and suggesting places to look. It looks like the session is lost whenever I make changes to my application, which is running on the development server (GAE 1.2.5).

Since my session is keeping the login credentials (i.e. OpenID), it looks like I may have to create a session driver (i.e. a faux session) while I'm developing, or log in every time I make a change.

Although those workarounds will work, I'd also be much obliged if you happened to have any suggestions for keeping sessions across restarts (during the development process).

Delete comment Comment 3 by brianmhunt, Yesterday (17 hours ago)

It seems I jumped the gun. I can't explain why the sessions mysteriously disappear. I'll keep probing with the suggestions you've helpfully given, Joseph, and follow up on here once I determine something conclusive. Thank you.

Delete comment Comment 4 by bowman.joseph, Today (7 hours ago)

I was using openid/oauth/facebook connect for my application, and had the same issue with the development server, but found it was not a problem on the live servers. I never took the time to track down the issue with the dev server, as I just found in general it had some oddities involved with restart, so I would just log back in.

brianmhunt commented 15 years ago

I'll try and root out the issue. It's bothering me. :-)

luddep commented 15 years ago

Any luck on narrowing down the issue?

joerussbowman commented 15 years ago

None here, I took a couple more stabs at it before the release, but it was to inconsistent to track down. I've since been working off of Appengine, so haven't had the opportunity to look at it more.