2

I'm using Beaker Session on Google App Engine to manage persistent data between HTTP requests.

Is it possible to access same session from GET and POST request?

I tried to get access to session object but they are not the same object:

def get(self):
    session = self.request.environ['test.beaker.session']
    ...

def post(self):
    session = self.request.environ['test.beaker.session']
    ...
Seunghoon
  • 5,632
  • 5
  • 35
  • 41
  • 1
    Have you tested this outside of Android? This post might be helpful: http://stackoverflow.com/questions/3407764/android-example-for-using-a-cookie-from-httppost-for-httpget – Sologoub Jul 18 '12 at 00:44
  • Thanks! I think that explains the issue because with POST I use BasicHttpContent with CookieStore but with GET I'm loading the webpage using WebView. – Seunghoon Jul 18 '12 at 01:12
  • @Sologoub Could we post a answer to this question? Then I can accept your answer. – Seunghoon Jul 18 '12 at 01:14
  • Done. Glad you found this helpful! – Sologoub Jul 18 '12 at 15:41

2 Answers2

1

Take a look at this post talking about implementing something similar: Android: Example for using a cookie from HttpPost for HttpGet

The answer is that you need to make sure that the session cookie is stored on the android client side and is accessible throughout the interaction with your server.

Community
  • 1
  • 1
Sologoub
  • 5,312
  • 6
  • 37
  • 65
0

They won't be the same object (object identity) from request to request (remember multiple servers). However with the correct setup the session will be consistent for a users session.

Without a custom backend (datastore or memcache for appengine) you can only use cookie based sessions. If you put something into the session you need to call session.save() or configure it for auto save. Have you done either of these in your code ?

How did you determine they are different, object identity or contents ?

You should provide some more details on how it is setup.

Tim Hoffman
  • 12,976
  • 1
  • 17
  • 29
  • With our service, user can login using POST method and some data is stored in the session and I want to access the data in another GET request. I added some data to session in POST request but I can't get the data in GET request. – Seunghoon Jul 18 '12 at 01:04