简体   繁体   English

Cookie在iPhone 5s(iOS 10.2.1)上不持久

[英]Cookies not persistent on iPhone 5s (iOS 10.2.1)

I know that many variants have been asked on this issue and I have tried nearly every suggested solution, but none have worked for me. 我知道在这个问题上已经问过许多变体,并且我几乎尝试了所有建议的解决方案,但没有一个对我有用。

I am developing a website that uses php to set a cookie as follows: 我正在开发一个使用php设置cookie的网站,如下所示:

setcookie('USER_ID', $user_id, time()+30*86400, '/', '.'.$_SERVER['SERVER_NAME'], false, true);

The goal is to recognize a returning user, prompt them to confirm that it is them, and then proceed where they left off last time they visited the site. 目的是识别回访的用户,提示他们确认是他们,然后继续进行上次访问该站点的操作。 There is an another option that requires them to reenter their user id, so all is not lost... but it is aggravating that I cannot get this to work. 还有另一种要求他们重新输入用户ID的选项,因此不会丢失所有信息……但是,更糟糕的是,我无法使它正常工作。

Here is the scenario when I visit the website using anything but Safari on iOS. 这是当我在iOS上使用Safari以外的任何方式访问网站时的情况。

  1. Launch browser and enter URL for my site. 启动浏览器,然后输入我的网站的URL。
  2. Enter UserID (and other required info) to start (or resume) work on the site 输入UserID(和其他必需信息)以开始(或继续)在网站上工作
  3. Work on the site a bit 在网站上工作一点
  4. Enter URL for any other site. 输入其他任何网站的URL。
  5. Re-enter URL for my site... I am returned to where I left off. 重新输入我网站的URL ...我回到了我停下的位置。
  6. Terminate browser 终止浏览器
  7. Relaunch browser and enter URL for my site. 重新启动浏览器,然后输入我的网站的URL。
  8. I am returned to where I left off 我回到了我停下的地方

Here is the scenario when I visit the website using Safari on iOS. 这是当我在iOS上使用Safari浏览网站时的情况。 (steps 1.-7. are the same) (步骤1.-7。相同)

  1. Site requires me to reenter UserID (and other required info) to resume work on the site 网站要求我重新输入UserID(和其他必需信息)才能继续在网站上工作

The ONLY test platform that I tested that has this issue is Safari on iOS. 我测试过的唯一有此问题的测试平台是iOS上的Safari。 I have tested Safari, Chrome, Firefox on both OSX and Windows, Chrome on iOS, and Chrome on Android. 我已经测试了Safari,Chrome,OSX和Windows上的Firefox,iOS上的Chrome和Android上的Chrome。 All of these work as expected. 所有这些工作都按预期进行。 The real kicker is that I have also tested using the iPhone 5s simulator that comes with Xcode and that also worked as expected. 真正的关键是我还使用了Xcode附带的iPhone 5s模拟器进行了测试,该模拟器也可以按预期工作。

I have checked, double checked, triple checked my "Block cookies" setting on my (physical) iPhone and it is clearly "Allow Always" 我已经检查了我的(物理)iPhone上的“阻止cookie”设置,对它进行了仔细检查,再三遍检查,显然是“允许始终”

在此处输入图片说明

I have connected the phone to my laptop using a USB cable and examined the cookies being set using WebInspector. 我已使用USB电缆将手机连接到笔记本电脑,并检查了使用WebInspector设置的cookie。 The USER_ID cookie IS being set immediately after step 2. The expiration date is 30 days into the future. 在第2步之后立即设置USER_ID cookie。有效期为未来30天。 The HTTP flag is set. HTTP标志已设置。 The path is '/'. 路径为“ /”。 The website is correct (I have tried both with and without the leading '.'). 该网站是正确的(我尝试了带或不带“。”的情况)。 The cookie is still set after step 5. The cookie is GONE at step 7 (relaunch of Safari and navigation to my site). 在第5步之后仍然设置cookie。在第7步(重新启动Safari并导航到我的网站),cookie消失了。

I have been ripping my hair out over this for the last 2 days. 在过去的两天里,我一直在扯头发。 Has anyone seen this before? 谁看过这个吗? Better yet, does anyone know what might be going on? 更好的是,有人知道会发生什么吗?

Thanks much, mike 谢谢,迈克

I borrowed a friend's iPhone and found they had no issue with my site. 我借了朋友的iPhone,发现他们的网站没有问题。

Came back to my phone and cleared all the browser history. 回到我的手机并清除了所有浏览器历史记录。 It started working. 它开始工作了。 Not sure what was in the history that caused this issue, but I'm moving on. 不确定导致此问题的历史是什么,但我正在继续。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM