问题描述:

I am writing an application with the user of Android Java " Eclipse " + Jquery Mobile + CodeIgniter Framework

I almost finished everything but still can not proceed on the push notification issue

one big problem taken about 2 days till now from me till I have headache from such conflict :

I made the POST Request from the android and it's already sending the POST Array.

here is the php code to handle the post request...

function notification() {

if($_POST['registrationId']) {

$this->session->set_userdata('registrationId', $_POST['registrationId']);

echo 'registerationID : success'.$this->session->userdata('registrationId').'====';

}

it really echo the session userdata indeed .. but when I try to use it in any other function or pages .. it's not working ? !!! it's empty or not existed ? !!

even when I try to make the query within the function in order to store it in Database .. the session is not available like $this->session->userdata('emailid')

update 'user' set deviceid ... where emailid = $this->session->userdata('emailid')

... not working and the session is not available !!!!!

PLEASE ANYONE CAN HELP ME ? !! :(

网友答案:

you can ues a class to storing the post data

class PostData {
    public static $registrationId = "";
}
//set data
function notification() {
    if(isset($_POST['registrationId']) && empty($_POST['registrationId']) {
        PostData::$registrationId = $_POST['registrationId'];
    }
}
// use data
$post_registrationId  = empty(PostData::$registrationId) ? PostData::$registrationId : "";
网友答案:

well i couldn't solve the problem through sessions .. therefore i used fopen and i have registered the registration ID in a file.txt to use it later after in the session then delete the file. hope it can help someone someday .. thank you for sharing and participating

相关阅读:
Top