librelist archives

« back to archive

Find which keys are in a session cookie.

Find which keys are in a session cookie.

From:
Adrian Ratnapala
Date:
2012-07-14 @ 16:10
This might be a Werkzeug question, so please tell me if it is.

Flask (or Werkzeug?) encrypts the values of session variables inside
the session cookie, but not the keys.  Thus I can check if a client is
logged into my app using:

               ck = next((ck for ck in c.cookie_jar if ck.name=='session'), {})
                assert ck.value.find('user_id')

But is there a less hackish way of doing it?  One that doesn't require
me to make assumptions about the storage format?

-- 
Adrian Ratnapala
mobile: +49 1515 277 0000

NGBitS GmbH
Rainer Strasse 7
83104 Osterm√ľnchen

Web: www.ngbits.com