Original author : Wilson Sumanang
Fixes and improvements author : Alexandre ZANNI
Imported from saruberoz.github.io
Fixes author : JBNRZ
- Python 3
- Flask
Use flask_session_cookie_manager3.py
with Python 3
usage: flask_session_cookie_manager.py [-h] {encode,decode} ...
positional arguments:
{encode,decode} sub-command help
encode encode
decode decode
options:
-h, --help show this help message and exit
usage: flask_session_cookie_manager.py encode [-h] -s <string> -t <string>
options:
-h, --help show this help message and exit
-s <string>, --secret-key <string>
Secret key
-t <string>, --cookie-structure <string>
Session cookie structure
usage: flask_session_cookie_manager.py decode [-h] [-s <string>] -c <string>
options:
-h, --help show this help message and exit
-s <string>, --secret-key <string>
Secret key
-c <string>, --cookie-value <string>
Session cookie value
$ python flask_session_cookie_manager.py encode -s "JBNRZ" -t "{'name':'JBNRZ'}"
eyJuYW1lIjoiSkJOUloifQ.ZZVJMg.ZPGcSUBQVYq5zVgSsVq-_4eFaaM
Note: the session cookie structure must be a valid python dictionary
With secret key:
$ python flask_session_cookie_manager.py decode -s "JBNRZ" -c "eyJuYW1lIjoiSkJOUloifQ.ZZVJMg.ZPGcSUBQVYq5zVgSsVq-_4eFaaM"
{'name': 'JBNRZ'}
Without secret key (less pretty output):
$ python flask_session_cookie_manager.py decode -c "eyJuYW1lIjoiSkJOUloifQ.ZZVJMg.ZPGcSUBQVYq5zVgSsVq-_4eFaaM"
b'{"name":"JBNRZ"}'