See the previous recipe, Creating a simple session-based authentication, to understand the complete working of this recipe. Flask provides a special object called g. You can read more about this at http://flask.pocoo.org/docs/1.0/api/#flask.g.