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

  • Home
  • SEARCH
  • 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 6078955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:53:31+00:00 2026-05-23T10:53:31+00:00

I´m currently developing an application on Android, using App Engine as a backend. Since

  • 0

I´m currently developing an application on Android, using App Engine as a backend. Since there´s some heavy parsing going on, I sometimes need to pass session cookies from the android device to the server, in order to be authenticated when parsing the response data.

The code below is from server side, where I put the Cookie(s) that is passed from my android device in the server HttpUrlConnection object. Now to my issue.

I´ve been having huge problems with not being authenticated even though I pass a valid session cookie to the server. After a couple of days of debugging, it seems like I found the issue today, but I have no clue on how to fix this.

Using Microsoft network monitor, I can see that SOMETIMES when I make the request from the server, but not always, there´s a second cookie in the request, BESIDES the one that I have put in the HttpUrlConnection. This seems to confuse the the 3rd party server, which responds with a Set-cookie, rather than letting me access the secure page.

The cookies look like this:

The cookie that I set
Cookie:  PHPSESSID=q5r4uon05a32vhs29cd65sarv6

The second cookie, that just "appears" when I make the request
Cookie:  $Version=0; PHPSESSID=hb94i7vopft13uaaob837lf3b0; $Path=/

So, what is this version 0 cookie, and how can I make sure that it is not passed in my request?

ArrayList<HashMap<String, String>> fillMaps = new ArrayList<HashMap<String, String>>();
URL page = null;
Scanner scanner = null;
Session session = null;
HttpURLConnection connection = null;
try {
    link = link.replace("&amp;", "&");
    page = new URL(FS_PARTIAL_SESSION_URL + link);


    StringBuilder sb = new StringBuilder();
    Iterator<Cookie> cooks = cookies.iterator();
    while(cooks.hasNext()) {
        Cookie cookie = cooks.next();
        sb.append(cookie.getName()+"="+cookie.getValue());
        if (cooks.hasNext()) {
            sb.append(";");
        }
    }

    connection = (HttpURLConnection) page.openConnection();
    connection.setRequestProperty("Cookie", sb.toString());
    scanner = new Scanner(connection.getInputStream());

} catch (MalformedURLException e) {
    log.log(Level.SEVERE, e.getMessage(), e);
} catch (IOException e) {
    log.log(Level.SEVERE, e.getMessage(), e);
}
finally {
    connection.disconnect();
}
  • 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-23T10:53:32+00:00Added an answer on May 23, 2026 at 10:53 am

    I finally solved this by creating my own “version 0” cookie. When doing so it seems like the second cookie doesn´t get created, or atleast my own cookie gets picked up instead. So in my while loop, the code now looks like this:

    Cookie cookie = cooks.next();
    sb.append("$Version=0; ");
    sb.append(cookie.getName()+"="+cookie.getValue());
    if (cooks.hasNext()) {
        sb.append(";");
    }
    sb.append("; $Path=/");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently developing an Android application that fetches images using http requests. It would
I am currently developing an application in Android Where I want to give some
I am currently developing an application that receives GPS data gathered using and android
I am currently developing an Android application which has a web backend. I can
I am having trouble with developing my Android application, I am currently using Eclipse
Currently developing an application using the newest version of symfony, obtained through PEAR. This
I am currently developing an android application uses Google map API. I am wondering
The app I'm currently developing depends on a third party application (OIFileManager). My question
I am currently developing an application for some researchers in my university.It's a small
I'm currently developing a application where I will have multiple windows open using C#

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.