简体   繁体   中英

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. 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). The issue is limited only to some specific Android devices and is not yet reported on any other platforms .

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. However, they are working perfectly fine (Session testing implementation link provided in PRG implementation link).

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.

List of devices of some of the users who reported the issue-

  • Moto Z Play, Android 7.0
  • Moto M, Android 7.0
  • Xiaomi Mi 4i, Android 5.0.2
  • 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.

Reference for PRG pattern implementation-
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

PRG Implementation-

<?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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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