iPad / iPhone:如何在Web应用程序中保持会话 [英] iPad/iPhone : how to keep the session in a web app

查看:328
本文介绍了iPad / iPhone:如何在Web应用程序中保持会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将网页添加为Web应用程序是很简单的。在这里找到一个不错的文章

It's straight forward to add a web page as a web application. Find here a nice article.

问题在于保持会话开放。切换到另一个应用程序后,会话将关闭,用户需要重新输入其凭据。

The issue know is keeping a session open. Once switching to another app the session is closed and the user needs to re-enter his credentials.

我在堆栈溢出

一些提示?

推荐答案

诀窍是这样做:

// Start or resume session
session_start(); 

// Extend cookie life time by an amount of your liking
$cookieLifetime = 365 * 24 * 60 * 60; // A year in seconds
setcookie(session_name(),session_id(),time()+$cookieLifetime);

我测试了这个在iOS 4.2.1,5.1.1,6.0和6.1上工作。在关闭并重新启动设备后,会话甚至会恢复。

I tested this to work on iOS 4.2.1, 5.1.1, 6.0 and 6.1. The session is even restored after turning off and restarting the device.

有关此策略的更详细讨论,您可以查看我对此问题的回答:
在iPhone上的网络应用中维护PHP会话

For a more elaborate discussion of this strategy you can take a look at my answer of this question: Maintain PHP Session in web app on iPhone

这篇关于iPad / iPhone:如何在Web应用程序中保持会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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