iOS Full Screen Web App drops cookies?

回眸只為那壹抹淺笑 提交于 2019-12-02 21:50:55

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!