On 28 syys, 15:05, Peter <[EMAIL PROTECTED]> wrote: > So I figure the first piece of the puzzle is to work our how to > store and retrieve cookies. Attempts using HttpResponse.COOKIES and > HttpResponse.get_cookie have met with failure. No attribute of that > name... > > Having got that working I figure I can create a user object and > stick it in the datastore. Then grab the key and wack it in the > cookie.
I do it along the following lines (parts copypasted from http://gaeutilities.appspot.com/session). First, give the user a cookie: sid = 'X' + sha.new(repr(time.time()) + os.environ['REMOTE_ADDR'] + str(random.random())).hexdigest() player = Player(key_name=sid) # this object obviously has other properties, like that nickname player.put() self.response.headers.add_header('Set-Cookie', 'SID=%s; path=/' % sid) Elsewhere, read that cookie data: sid = self.request.cookies.get('SID', None) if sid is not None: player = Player.get_by_key_name(sid) if player is not None: ... j --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---
