从以前的位置恢复webapp? [英] resume webapp from previous position?

查看:129
本文介绍了从以前的位置恢复webapp?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个webapp,用于在用户数据进展时存储这些数据,以便他们在iPhone上的主屏幕应用模式下点击外部链接并让应用程序查看网页或类似内容。

I have a webapp which stores the users data as they progress so that if they click on an external link while in the home screen app mode on an iPhone and leave the app to view a webpage or similar.

当他们返回webapp时,将如何在同一位置恢复。
目前它没有进入相同的位置,它重定向到主页我希望它从以前的位置恢复...

When they return the webapp how will resume at the same position.? currently its not going to same position, its redirecting to home page i want its resume from previous position..

如何做到这一点,任何想法?

How to do this, any idea?

推荐答案

从大多数情况下,Web应用程序无法从中断处继续,因为用户正在存储Web应用程序图标(假设在iOS设备上)在其主屏幕上实际上是一个书签,它只是在返回到Web应用程序时将该特定网页作为Web应用程序启动。

It's not (for the most part) possible for a web app to resume where it left off, because since the user is storing the web app icon (assuming on an iOS device) as what is essentially a bookmark on their homescreen, it just launches that specific web page as the web app when they go back into the web app.

然而,你可以做的是设置一个cookie(通过PHP或Javascript)等于用户每次在移动应用中查看页面时正在查看的完整URL。例如(在PHP中):

What you COULD do however, is set a cookie (via PHP or Javascript) equal to the full URL that the user is viewing every time the user views a page in the mobile app. For example (in PHP):

//--- Set lastPage cookie for 24 hrs for your domain --- //
setcookie('lastPage', 'http://www.example.com/products/bicycles', time()+86400, '/');

答案:

在您的主页上,在显示任何内容之前,如果设置了 $ _ COOKIE ['lastPage'] ,请使用PHP(或选择的语言)进行检查。如果是,请执行if语句将用户重定向到最后查看的页面。

On your homepage, before displaying any content, check with PHP (or language of choice) if $_COOKIE['lastPage'] is set. If it is, perform an if statement redirecting the user to that last viewed page.

<?php
    if(isset($_COOKIE['lastPage'])) {
        header('location: '.$_COOKIE['lastPage']);
        exit();
    } 
?>

这对用户来说是无缝的,并且会使其看起来好像网络应用程序是记住 他们的会议。因此,在主页以外的每个页面的顶部,您将在显示任何内容之前放置下面的代码(替换 pageUrl 中的URL以获取每个页面的实际URL ):

This will appear seamless to the user, and will make it appear as if the web app is "remembering" their session. So at the top of every page other than the homepage, you would place the code below before any content is displayed (replacing the URL in pageUrl for the actual URL of each individual page):

<?php     
    $pageUrl = 'http://www.example.com/products/bicycles/';
    setcookie('lastPage', $pageUrl, time()+86400, '/');
?>

循环数据库结果:

<?php     
    foreach(database['row'] as $variableName => $variableValue) {
        setcookie($variableName, $variableValue, time()+86400, '/');
    }
?>

这篇关于从以前的位置恢复webapp?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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