views:

32

answers:

1

I want set another cookie when user login, I use google.appenine.api.users.create_loginurl() to create the login url, it's /_ah/login, how can I extend this handler and add another cookie. The same as logout.

+1  A: 

One option: You could create landing pages to set or unset your app cookies. create_login_url takes a destination url as an argument, redirect to your page that sets up your cookie. To logout, forward users to a page that unsets the cookie then redirects them on to the log out page.

Another choice would be to check the user is logged in, if they are make sure the right cookie is set. If they are not logged in make sure the cookie is not set. The specifics of setting this up will depend on how which framework you are using.

A common approach is to create a BaseRequestHandler class as a subclass of webapp.Requesthandler. BaseRequestHandler can then ensure users have the correct permissions to view a particular page, handle errors, setup up template rendering paths, and setup user sessions in a standard way for your app.

Robert Kluin