更新时间:2023-10-18 10:29:10
你将不得不写一个Express或Django的自定义会话存储。默认情况下,Django(以及django-redis-sessions)将会话存储为腌制的Python对象。将会话快速存储为JSON字符串。 Express,with connect-redis,在redis中的密钥 sess:sessionId
下存储会话,而Django(不完全确定)似乎将它们存储在密钥的sessionId
。您可能可以使用django-redis-sessions作为基础,并覆盖 encode
, decode
, _get_session_key
, _set_session_key
或许还有其他几个。您还必须确保以相同的方式存储和加密Cookie。
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.
显然,为Express创建可以腌制的会话存储将变得更加困难并解开Python对象。
Obviously, it will be way harder to create a session store for Express that can pickle and unpickle Python objects.