iOS全屏Web应用程序删除Cookie? [英] iOS Full Screen Web App drops cookies?

查看:155
本文介绍了iOS全屏Web应用程序删除Cookie?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经历过,当您开始/退出保存到信息中心(全屏模式)的网络应用时,iOS4会丢弃Cookie。



这是真的,解决方案

这不是一个错误,它是一个功能。



现在您的问题可能是:如何设置我的Cookie生命周期?假设你使用PHP,代码片段是:

  $ lifetime = 31536000; //一年
setcookie($ varName,$ varValue,time()+ $ lifetime);

如果您使用PHP会话,则必须重写Cookie以添加大于0:

  setcookie(session_name(),session_id(),time()+ $ lifetime); 

通常,您不必为了更改默认生命周期而重写会话cookie,函数 session_set_cookie_params 应该让你这样做,但我发现并不总是这样。


I have experienced that iOS4 drops cookies when you start/exits a web app saved to the dashboard (full screen mode).

Is it true and is there a workaround?

解决方案

It's not a bug, it's a feature. Session cookies (i.e. cookies with a lifetime of 0) are dropped at the end of the browser session — which, in the case of a full screen web app, happens as soon as you leave the web app. If you want them to persist, just set your cookie lifetime to something larger than the default 0 (I use 1 year).

Now your question might be: how do I set my cookie lifetime? Assuming you're using PHP, the piece of code would be:

$lifetime = 31536000; // one year 
setcookie($varName,$varValue,time()+$lifetime); 

If you're using PHP sessions, you will have to rewrite the cookie to add a lifetime greater than 0:

setcookie(session_name(),session_id(),time()+$lifetime);

Normally, you shouldn't have to rewrite the session cookie in order to change the default lifetime, as the function session_set_cookie_params should let you do just that, but I found it's not always the case.

这篇关于iOS全屏Web应用程序删除Cookie?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆