iphone 书签 cookie 持久性
我有一个 iPhone(基于 jqtouch)网络应用程序,它使用 cookie 进行身份验证。使用流程如下:
用户转到移动登录页面,并被指示将该页面另存为主页上的书签。
他们启动小书签以转到登录页面进行登录并获取 cookie。
cookie 有效,他们可以在整个网站中导航。
但是此会话 cookie 不是持久的。如果他们离开 safari,然后使用保存的小书签重新启动,则在上一个会话期间设置的 cookie 就会消失。
仅使用 safari(即:直接启动 safari,而不是通过小书签)来导航页面就可以正常工作(即:启动 safari,转到 url,登录,重新启动 safari,返回 url)。
我发现创建小书签时处于活动状态的 cookie 是持久性的,但通过小书签访问 safari 时在会话期间设置的任何 cookie 都不是持久性的。
我想知道这是否是 safari/iphone 问题和/或是否有任何解决方法。非常感谢您提供的任何见解。
I have an iphone (jqtouch based) web app that uses cookies for authentication. The use flow is as follows :
user goes to the mobile landing page and is instructed to save the page as a bookmarklet on their home page.
they launch the bookmarklet to go to a login page to login and get a cookie.
the cookie works and they can navigate throughout the web site.
However this session cookie is not persistent. If they leave safari and then restart using the saved bookmarklet, the cookies set during their previous session are gone.
Just using safari (ie: launch safari directly rather than through the bookmarklet) to navigate the pages works fine (ie: start safari, go to url, do login, restart safari, go back to url).
I find that that the cookies that were active when the bookmarklet was created are persistent but any cookies set during the session when safari is accessed through the bookmarklet are not persistent.
I'm wondering if this is a safari/iphone issue and/or if there is any way around this. Many thanks for any insight you can provide.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
K,对于遇到同样问题的人,我通过使用 html5 的本地存储找到了解决方法。我只需要使用 javascript 在设置 cookie 时根据 cookie 值设置存储,并在加载第一页时根据存储值设置 cookie。
K, for anyone encountering the same problem, i found a work around by making use of html5's localstorage. I just needed to use javascript to set the storage based on cookie values as the cookies were being set and to set the cookies from the storage values when the first page was loaded.
我已经在我的一个应用程序中尝试过这一点。我已经尝试过这种方式:
我知道这听起来很困难,但实际上很容易。您只需阅读 Apple 关于 NSHTTPCookie 的文档即可。
I have tried that in one of my applications. I have tried this in this way:
I know it sounds difficult but infact is really easy. All you have to go through is Apple's documentation on NSHTTPCookie.