简体   繁体   English

PHP后重定向获取在某些特定的Android设备中失败

[英]PHP Post-Redirect-Get failing in some specific Android devices

I referred an article(reference link provided at the bottom) to implement Post-Redirect-Get(PRG) pattern(implementation link provided at the bottom) in PHP. 我引用了一篇文章(底部提供了参考链接)来实现PHP中的Post-Redirect-Get(PRG)模式(底部提供了实现链接)。 It works perfectly in most of the devices ; 在大多数设备中都能完美地工作 ; however it does not work in some specific devices . 但是它不适用于某些特定设备 I found this after some users reported that they were unable to register a new account(I have used this same implementation of PRG there). 在一些用户报告说他们无法注册新帐户之后,我发现了这一点(我在那儿使用了PRG的同一实现)。 The issue is limited only to some specific Android devices and is not yet reported on any other platforms . 该问题仅限于某些特定的Android设备尚未在其他任何平台上报告

The users who face this issue are facing it in all browsers in their device. 面对此问题的用户在其设备的所有浏览器中都面临着该问题。

Initially, I suspected that this issue is related to PHP SESSION and I thoroughly tested sessions in those devices. 最初,我怀疑此问题与PHP SESSION有关 ,因此我对这些设备中的会话进行了全面测试。 However, they are working perfectly fine (Session testing implementation link provided in PRG implementation link). 但是,它们工作得很好 (PRG实施链接中提供了“会话测试实施”链接)。

I don't have any device which has this issue and so I am unable to reproduce this issue myself. 我没有任何设备存在此问题,因此我无法自己重现此问题。 I tried debugging with help of my friends who faced this issue, thus I am still able to reproduce it indirectly. 我在遇到此问题的朋友的帮助下尝试进行调试,因此,我仍然能够间接复制它。

It is possible that you might be unable to reproduce this issue as well, in which case, please have a look at code and see if anything is wrong. 您也可能无法重现此问题 ,在这种情况下,请查看代码,看看有什么问题。

Out of 2000 users, only 30-50 users faced this issue. 在2000个用户中,只有30-50个用户面临此问题。

List of devices of some of the users who reported the issue- 报告此问题的某些用户的设备列表-

  • Moto Z Play, Android 7.0 Moto Z Play,Android 7.0
  • Moto M, Android 7.0 Moto M,Android 7.0
  • Xiaomi Mi 4i, Android 5.0.2 小米Mi 4i,Android 5.0.2
  • OnePlus 5, Android 7.0 OnePlus 5,Android 7.0

Note - I haven't tested this issue in multiple devices of above mentioned models, that is, it might be possible that the same PRG implementation works in all OnePlus 5 models, except for the one in which the issue was reported. 注意 -我尚未在上述型号的多个设备中测试此问题,也就是说,除了报告该问题的那个型号外,所有其他OnePlus 5型号都可能使用相同的PRG实现。

Reference for PRG pattern implementation- PRG模式实施参考-
http://wordsideasandthings.blogspot.in/2013/04/post-redirect-get-pattern-in-php.html http://wordsideasandthings.blogspot.in/2013/04/post-redirect-get-pattern-in-php.html
Implementation which demonstrates the issue( in those specific devices only )- 演示问题的实现( 仅在那些特定设备中 )-
http://witch-hunt-crewmemb.000webhostapp.com/stackoverflow/prg/echochamber.php http://witch-hunt-crewmemb.000webhostapp.com/stackoverflow/prg/echochamber.php

PRG Implementation- PRG实施-

<?php
session_start();

$echoedShout = "";

if(count($_POST) > 0) {
    $_SESSION['shout'] = $_POST['shout'];

    header("HTTP/1.1 303 See Other");
    header("Location: http://witch-hunt-crewmemb.000webhostapp.com/stackoverflow/prg/echochamber.php");
    die();
}
else if (isset($_SESSION['shout'])){
    $echoedShout = $_SESSION['shout'];

    /*
        Put database-affecting code here.
    */

    session_unset();
    session_destroy();
}
?>

Session Testing Implementation- 会话测试实施-

<?php
session_start();
if(isset($_SESSION['y'])){
    $x=$_SESSION['y'];
    unset($_SESSION['y']);
}
else{
    $_SESSION['y']='b';
    $x='a';
}
echo $x;
?>

The problem occurred with devices with chrome data saver enabled. 启用了chrome数据保护程序的设备出现了问题。 Disabling it immediately solved the problem. 禁用它可以立即解决问题。 It occurred only on android devices because 'enable chrome data saver' prompt is shown on chrome android, but on desktop it needs to be explicitly installed from chrome web store. 它仅在android设备上发生,因为chrome android上显示“启用chrome数据保护程序”提示,但在台式机上则需要从chrome网上商店中明确安装。

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

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