Skip to content Skip to sidebar Skip to footer

How To Share Sessions Between Modules On A Google App Engine Python Application?

I'm trying to make a basic app on Google App Engine with two modules using Google App Engine Modules(https://developers.google.com/appengine/docs/python/modules/) and They share se

Solution 1:

By default webapp2_extra.sessions uses cooki-based sessions. These will be tied to a specific domain. Your modules are probably at module1.yourapp.appspot.com and module2.yourapp.appspot.com (a guess). The second module won't be able to see the cookies set by the first module.

In your config try setting the domain for the cookie.

config['webapp2_extras.sessions'] = {
    'secret_key': 'my-super-secret-key',
     cookie_args': { 
         'domain' : "yourapp.appspot.com"
}

The docs say:

- domain: Domain of the cookie. To work accross subdomains the
   domain must be setto the main domain with a preceding dot, e.g.,
   cookies setfor `.mydomain.org` will work in `foo.mydomain.org` and
   `bar.mydomain.org`. DefaultisNone, which means that cookies will
   only work for the current subdomain.

from: https://code.google.com/p/webapp-improved/source/browse/webapp2_extras/sessions.py

Or you could also use one of the other backends like memcache or datastore. This is preferred if your sessions contain sensitive info.

Post a Comment for "How To Share Sessions Between Modules On A Google App Engine Python Application?"