Reputation: 2536
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.
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.
Upvotes: 5
Views: 5862
Reputation: 17170
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.
It'd look something like this:
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
Are web sockets supported? You could use Socket.io to do the transport, which would be a lot less latency.
Upvotes: 5
Reputation: 6968
I am almost sure you will want to use cookies. The other alternative would be to append a session id to every request via a url param and persist this across your app leveraging some kind of middleware to make sure its appended to every URL. You could do this by parsing your responses or by hijacking your template engine to include this in every link and form. I find it really strange the iOS doesn't havent cookies. I am almost sure that this is incorrect, can you please link where you read that?
Upvotes: 2