Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8497255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:04:54+00:00 2026-06-11T00:04:54+00:00

In my application I am trying to retreve data from server using api.Since I

  • 0

In my application I am trying to retreve data from server using api.Since I was trying to get the facebook data I am passing facebookid when i call the url for the first time.The code is suchthat it should get data from the server when another url is called.

My problem is that I am getting a null value when I call the url for the second time.That is here the session is getting deleted.
My code is given below.

public void getdetails(){
    JSONObject json = JSONfunctions.getJSONfromURL(unielement+"UserLogin.php?faceid="+facebookID);
    System.out.println(unielement+"UserLogin.php?faceid="+facebookID+"   "+json);

    try{
        JSONArray  data = json.getJSONArray("data");
        //Loop the Array
        for(int i=0;i < data.length();i++){                      

            ArrayList<String> list = new ArrayList<String>();

            list.add(data.getJSONObject(0).getString("CreditBySelf"));
            list.add(data.getJSONObject(0).getString("CreditThroughFriend"));
            list.add(data.getJSONObject(0).getString("ForUser"));
            list.add(data.getJSONObject(0).getString("LDrawTicket"));
            list.add(data.getJSONObject(0).getString("Buy-In"));
            list.add(data.getJSONObject(0).getString("RemVote"));
            list.add(data.getJSONObject(0).getString("Voted"));
            StringBuilder sb = new StringBuilder();
            for (String s : list)
            {
                sb.append(s);
                sb.append("\t");
            }
            uid = list.get(0);
            name = list.get(1).toString();
            System.out.println(list);
            textView_name1.setText(name);

        }
    }
    catch(JSONException e1){
        Toast.makeText(getBaseContext(), "No name Found"+e1 ,Toast.LENGTH_LONG).show();
    } catch (ParseException e1) {
        e1.printStackTrace();
    }

}

When I call the above function a session is created and it should be there when I call the below code.

public void getdataforsharing(){

    JSONObject json = JSONfunctions.getJSONfromURL(unielement+"userfbaction.php");
    System.out.println(unielement+"userfbaction.php    "+json);

    try{
        JSONArray  wholedata = json.getJSONArray("data");
        System.out.println(wholedata);
        JSONObject  data = wholedata.getJSONObject(0);
        System.out.println(data);
        //Loop the Array
        for(int i=0;i < data.length();i++){                      

            list1 = new ArrayList<String>();
            /*list1.add(data.getJSONObject(0).getString("wall_image"));
            list1.add(data.getJSONObject(0).getString("wall_title"));
            list1.add(data.getJSONObject(0).getString("wall_Description"));*/
            list1.add(data.getString("wall_image"));
            list1.add(data.getString("wall_title"));
            list1.add(data.getString("wall_Description"));

            StringBuilder sb = new StringBuilder();
            for (String s : list1)
            {
                sb.append(s);
                sb.append("\t");
            }
            System.out.println("Share on facebook"+list1.get(0));
        }
    }
    catch(JSONException e1){
        Toast.makeText(getBaseContext(), "No name Found"+e1 ,Toast.LENGTH_LONG).show();
    } catch (ParseException e1) {
        e1.printStackTrace();
    }
}

When I call this function I am not getting the session that is created by the first funcion and I am getting a null data.

What is wrong in this?Anyone help me please.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T00:04:55+00:00Added an answer on June 11, 2026 at 12:04 am

    The session is created in “UserLogin.php”.

    Sessions are controlled in PHP by use of a SessionID which can be either:

    1. passed as a query parameter; you need to receive the session ID, then add to the URL next time you call, or
    2. passed in a cookie; you need to receive the cookie, then send the cookie to the URL next time you call.

    Your code is doing neither: you’re only accepted the JSON back, you’re not reading in the cookie and sending next time, nor are you receiving a SessionID in the data and using it with the next call.


    Easiest solution in your case:

    1. In the first call, return the contents of “session_id()” as part of your json. Remember it for later, store in memory or in a file – however you need it.
    2. In the second call to userfbaction.php, send that session_id as a parameter
    3. In userfbaction.php, read the parameter and call “session_id()” passing in the session_id before session_start(). This will then continue the previous session
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get a simple GXT application to retrieve data from an external
I am trying to get serialized results from a WCF service from database using
I'm trying to retrieve data from http://api.freebase.com/api/trans/raw/m/0h47 As you can see in text there
Using PyClips, I'm trying to build rules in Clips that dynamically retrieve data from
I am trying to retrieve data from MySQL for a flash application via PHP,
I am trying to retrieve JSON data from an external text file using a
I'm trying to drag data from the Winforms portion of my application on a
I'm trying to enable service discovery in my client-server application using JmDNS. I fully
I am trying to retrive data to my SL application from PHP, MySQL service
I'm a hobby programmer trying to build a client/server application suite, using Delphi XE.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.