[Flask] Setting global flag and keeping it in the session

Jonathan Chen tamasiaina at gmail.com
Sat Jul 25 19:21:48 CEST 2015

A quick tutorial of sessions can be found in the documentation here:

There is a difference between g object and sessions. Sessions use cookies
to store information. The neat thing with the session object is that you
can interface it into another datastore like redis or mongo. The g object
is attached to the request so information or data that you put into the g
object does not persist between different requests while session object

~Jonathan C.

On Thu, Jul 23, 2015 at 5:57 AM, Jim Icenhower via Flask <flask at python.org>

> Hi,
> I'm a fairly new user of Python and Flask but I am a professional Java
> developer.
> I have started creating an app using the Flask Appbuilder.  I would like
> to set a value from the user's login record (accountId) when he logs in and
> have it be available for queries on future hits during his session. I know
> I could include a join to the user's record to get accountId with every
> query but it seems it might be more efficient to store accountId in the
> session and add it to the WHERE clause of any queries.
> Also, it seems like handling session variables would be a good thing to
> know in general.
> Can anyone give me a clue about how to store and retrieve session
> variables? I've seen the g object but I'm not sure how to use it or if
> that's the best way to do this. I'm actually not sure that the g object
> persists across hits.
> Thanks for any help!
> Jim
> _______________________________________________
> Flask mailing list
> Flask at python.org
> https://mail.python.org/mailman/listinfo/flask
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20150725/4a965713/attachment.html>

More information about the Flask mailing list