The_Martian
The_Martian

Reputation: 3767

php session to pass variables (from android app) to another page

I have two android separate apps sending data to php(xampp) server. I am sending data from app1 to test1.php and from app2 to test2.php. After that I would like to access the data from test1.php using session and do some stuff in app2.php. I am successful in sending the data from my android apps. But I am not getting the data in test2.php. This is test1.php.

<?php 
        //session 
        session_start();

        $json = file_get_contents("php://input");
        $jsondecoded = json_decode($json, TRUE);
        $Id = $jsondecoded['ID'];  

        $_SESSION['id'] = $Id;
?>

Here is test2.php

<?php 
        //session
        session_start(); 

        $myid=$_SESSION['id'];
?>

Upvotes: 2

Views: 429

Answers (1)

taxicala
taxicala

Reputation: 21759

Your problem is that app1 and app2 will start different sessions. You will never be able to have the same session in both apps if you don't share the session_id between them.

Upvotes: 2

Related Questions