Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6161207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:26:19+00:00 2026-05-23T21:26:19+00:00

The way I can authenticate my users in AppEngine using Google Accounts is simply

  • 0

The way I can authenticate my users in AppEngine using Google Accounts is simply wonderful.

However, I need to use my custom authentication-login system.

I will have a AppUsers table, with usernames and encrypted passwords.

I read something about sessions on gae, but I need help on starting up my app security.

How can I track my authenticated user session? Setting a cookie?

A beginner.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T21:26:20+00:00Added an answer on May 23, 2026 at 9:26 pm

    You can use cookie to do so… It is really not so hard. You can use cookie to track user’s authenticated and store the session key in gae datastore.

    There is an example (It just show the basic idea, I don’t guarantee the code can be used directly)

    The Basic User Table:

    # simply add an property to store the session key
    class User(db.Model):    
        username = db.StringProperty()
        password = db.StringProperty()
        session = db.StringProperty()
    

    The Login function

    # Do the following step:
    # 1. make sure user provide correct username and password
    # 2. generate a random session key 
    # 3. store the session key to datastore
    # 4. set the session key and user name in cookie
    class LoginAPI( Webapp.RequestHandler ):   
        def get(self):
            username = self.getVar( 'username', username )
            password = self.getVar( 'password', password )
    
            user = User.all().filter("username = ", username).get()
            password = encrypted_the_password(password) # encrypted your password with your own method!
    
            if user.password == password:
                 # User login successfually
                 session = generate_random_session_key() # generate your session key here
                 user.session = session
                 user.put()
    
                 expires_time = decide_your_expires_time() # decide how long the login session is alive.
                 cookie_time_format = "%a, %d-%b-%Y %H:%M:%S GMT"
                 expires_datetime = datetime.datetime.fromtimestamp(expires_time)
    
                 # set cookie as session
                 self.response.headers.add_header( "Set-Cookie", "user=%s; expires=%s; path=/" % ( user.username,expires_datetime.strftime( cookie_time_format ) ) )
                 self.response.headers.add_header( "Set-Cookie", "session=%s; expires=%s; path=/" % ( user.session, expires_datetime.strftime( cookie_time_format ) ) )
            else:
                 #User login failed
                 pass
    

    The logout function

    # Remove the previous cookie info 
    class LoginAPI( Webapp.RequestHandler ):
            def get(self):
                # remove the cookie
                self.response.headers.add_header( "Set-Cookie", "user=%s; expires=%s; path=/" % ( "",expires_datetime.strftime( cookie_time_format ) ) )
                self.response.headers.add_header( "Set-Cookie", "session=%s; expires=%s; path=/" % ( "", expires_datetime.strftime( cookie_time_format ) ) )
    

    When you required user login

    # Get the session info from cookie. If the session info match the info stored in datastore
    # Then user authenticate successfully.
    class SomePage(Webapp.RequestHandler):
        def get(self):
            # get cookie info
            username_from_cookie = self.request.cookies.get("user", "")
            session_from_cookie = self.request.cookies.get("session", "")
    
            if username_from_cookie and session_from_cookie:
                user = User.all().filter("username = ", username_from_cookie).get()
                if user.session == session_from_cookie:
                    # the user is login correctly
                    pass
                else:
                    # the user is not login
                    pass
            else:
                # the user is not login
                pass
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our dovecot and email server authenticate users using SHA1 digests. We can't really change
Is there some way I can use URLs like: http://www.blog.com/team-spirit/ instead of http://www.blog.com/?p=122 in
Is there some way I can define String[int] to avoid using String.CharAt(int) ?
I have an application built with GWT/Appengine/Jdo...and i am using Google User Service for
We're currently developing a Windows Smartclient that needs to authenticate users using their AD
I need to find a way to force Apache to ask users for credentials
I'm using Spring Security 3.04 to authenticate the users of my system using 3
I'm developing an ASP.NET app (c#) that need to authenticate users. To do that
I was wondering if there was any simple way to authenticate Openfire users against
in what way can I output the reference of an object in memory. Like:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.