Sharing a session store on Redis for a Django and a Express.js Application Sharing a session store on Redis for a Django and a Express.js Application express express

Sharing a session store on Redis for a Django and a Express.js Application


You will have to write a custom session store for either Express or Django. Django, by default (as well as in django-redis-sessions) stores sessions as pickled Python objects. Express stores sessions as JSON strings. Express, with connect-redis, stores sessions under the key sess:sessionId in redis, while Django (not totally sure about this) seems to store them under the key sessionId. You might be able to use django-redis-sessions as a base, and override encode, decode, _get_session_key, _set_session_key and perhaps a few others. You would also have to make sure that cookies are stored and encrypted in the same way.

Obviously, it will be way harder to create a session store for Express that can pickle and unpickle Python objects.