问题描述
我一直在尝试,但我发现,iOS 5默认情况下不接受cookie。我一直在尝试许多不同的事情,甚至使用Redis,但仍然不能得到一个会话持续多个请求。
I have been trying but I have found out that iOS 5 by default doesn't accept cookies. I have been trying many different things even using Redis but still cannot get a session to persist for more than one request.
没有使用cookies,我还有其他会话选项?我将使用Redis滚动一个粗略的会话模块,我只是发送自己的会话id到/从但似乎很容易刹车。
Without using cookies, what other session options do I have? I am about to roll a crude session module using Redis where I just send my own "session id" to and from but that seems like it could easily brake.
推荐答案
如果你不能让客户端支持cookies,也许你可以将一些数据放到LocalStorage中,然后将它们传递给服务器以连接到会话,并将其结构化为单页应用程序。
If you cannot get the client to support cookies, perhaps you can put some data into LocalStorage, and then communicate that up to the server to connect to the session, and structure it like a single-page app.
它看起来像这样:
server | client
send initial payload, with token --> store token in LocalStorage
initial payload contains some script
<-- XHR request for /data?sessid=XXXXX
look up session, do stuff --> handle result, update DOM, do more XHR
你可以使用Socket.io做传输,这将是一个很少的延迟。
Are web sockets supported? You could use Socket.io to do the transport, which would be a lot less latency.
这篇关于没有Cookie的Node.JS会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!