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 4626000
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:21:16+00:00 2026-05-22T03:21:16+00:00

I am building a login application in android in which i am hitting a

  • 0

I am building a login application in android in which i am hitting a url(with username and password) upto that part it works fine but after that whenever I am hitting a url(once the user is authenticated) , it return nothing(i.e. a error message like please login first). However it works fine in very similar iphone app and on browser.

I got somewhere that it is the error of phpSessionId(i.e. the session is destroyed for further request) and If we want our Android application to stay authenticated on the server side we need to fetch that id after the first connection and then send it in the headers of all our subsequent requests.

But the problem is that I am unable to get the sessionId from header of the first connection and sending it with further request along with the header.

Please give me some codes or links to complete the task properly.
Thanks.

  • 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-05-22T03:21:17+00:00Added an answer on May 22, 2026 at 3:21 am

    Finally I solved the issue of session handling in Android.
    Android cant handle the session itself(which a simple browser can) so we have to handle it explicitly.
    I changed the code for http connection a bit.
    Created an instance of DefaultHttpClient in the first Activity when connection established.

    public static DefaultHttpClient httpClient;
    

    For the first time connection,I did the following:

    URL url=new URL(urlToHit);
    LoginScreen.httpClient = new DefaultHttpClient(); //LoginScreen is the name of the current Activity
    
    HttpPost httppost = new HttpPost(url.toString());
    HttpResponse response = LoginScreen.httpClient.execute(httppost); 
    
    xr.parse(new InputSource(url.openStream())); //SAX parsing
    

    Now for all further connections I used the same httpClient
    For example in the next activity:

    URL url=new URL(urlToHit);
    
    HttpPost httppost = new HttpPost(url.toString());
    HttpResponse response = LoginScreen.httpClient.execute(httppost); 
    
    // Log.v("response code",""+response.getStatusLine().getStatusCode());
    
    // Get hold of the response entity
    HttpEntity entity = response.getEntity();
    
    InputStream instream = null;
    
    if (entity != null) {
        instream = entity.getContent();
    }
    xr.parse(new InputSource(instream)); //SAX parsing
    

    Hope this will help you all too to solve session issue in Android.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a twitter application that is currently using the classic login instead
I am building a ZendFramework application which as a login form asking for an
I am building a web application from scratch that has registration and login functionality.
I am building a twitter application that is currently using the classic login instead
Im building a web application which is a process management app. Several different employee
I'm building Rails application and I want to have user registration/login functionality. I also
I am building a web application where i got trapped in login module. I
I need to implement a login feature for the web application that I am
Building a client-side swing application what should be notified on a bus (application-wide message
When building static libraries with VS2005 I keep getting linker warnings that VC80.pdb cant

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.