Take the 2-minute tour ×

I was wondering about implementing my own sessions (more for an exercise than anything else) for a GAE app I'm working ... at first I was thinking of using the datastore to store the session data. However, every time something needs to be added to the session 'bucket', it would require saving to the datastore. Obviously that's bad since we want to minimize our writes. Then I thought about using memcache ... seemed like a good idea but then we're faced with issues of possible session corruption due to memcache being "evicted through memory pressure" by Google. So does that mean we are left with only the following options:

  1. Storing all session data in cookies
  2. Writing all session data to datastore and memcache, and then only reading from memcache

Anyone have any other ideas?

share|improve this question
add comment

3 Answers

up vote 3 down vote accepted

I suggest checking out (and contributing to) these three implementations of appengine sessions before rolling out your own:

Your options look fine but choosing between them probably depends on the size of the session data in your application.

share|improve this answer
@Alexander Kojevnikov: Looks like appengine-utilities link is broken. –  Brian M. Hunt Sep 29 '09 at 23:29
@Brian: Fixed, thanks! –  Alexander Kojevnikov Oct 6 '09 at 5:49
Another one to consider: gae-sessions is the fastest and simplest implementation available. A comparison of the available libraries is here: wiki.github.com/dound/gae-sessions/… –  David Underhill May 15 '10 at 19:44
add comment

UPDATE - 21 Mar 2011

At the time of this answer app-engine-patch is discontinued and gaeutilities offer worst features than gae-sessions.

share|improve this answer
add comment

If you use web2py (version 1.46 or latter) sessions are on by default on GAE. This achieved by the following three lines of web2py code at the top of the scaffoling model:

from gluon.contrib.gql import *

Here is a sample action that counts:

def index():
    session.c=session.c+1 if session.c else 1
    return dict(counter=session.c)
share|improve this answer
add comment

Your Answer


