mbr / flask-kvsession

A drop-in replacement for Flask's session handling using server-side sessions.
http://pythonhosted.org/Flask-KVSession/
MIT License
168 stars 53 forks source link

Expecting for namespace of key and native expiring support #14

Closed qiangwang closed 10 years ago

flexd commented 10 years ago

I agree it should be possible to namespace the keys.

Currently you just end up with a massive list of randomly generated keys.

mbr commented 10 years ago

As of simplekv 0.9.2, this can be achieved using PrefixDecorator:

store = ...  # setup store normally
prefixed_store = PrefixDecorator('sessions_', store)

# ...

KVSessionExtension(prefixed_store, app)

The decorator will transparently prefix sessions_ to every session key stored and strip it upon retrieval. See the simplekv docs for details.