iphone 书签 cookie 持久性

发布于 2024-08-26 06:50:52 字数 567 浏览 3 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不忘初心 2024-09-02 06:50:52

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.

挽容 2024-09-02 06:50:52

我已经在我的一个应用程序中尝试过这一点。我已经尝试过这种方式:

  1. 用户登录并将他的cookie设置到sharedHttpCookieStorage中。
  2. 根据您的 URL 检查 cookie,获取其值并将其保存在应用程序的存储中。
  3. 下次用户想要使用您的应用程序时,请检查您的存储中是否有任何 cookie 值。如果是,则使用这些值创建一个 cookie,否则让他再次登录。
  4. 确保在用户注销或 Cookie 过期日期到来时清除 Cookie 值。

我知道这听起来很困难,但实际上很容易。您只需阅读 Apple 关于 NSHTTPCookie 的文档即可。

I have tried that in one of my applications. I have tried this in this way:

  1. The user logs in and his cookie is set into the sharedHttpCookieStorage.
  2. Check the cookie against your URL, get its values and save it in your application's storage.
  3. Next time user wants to use your application, check if there is any cookie values in your storage. If Yes then create a cookie with those values else get him to log in again.
  4. Make sure to clear the cookie values when the user logs out or the cookie expiration date reaches.

I know it sounds difficult but infact is really easy. All you have to go through is Apple's documentation on NSHTTPCookie.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文