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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:50:06+00:00 2026-05-31T18:50:06+00:00

I am currently working on a mobile app that is going to communicate with

  • 0

I am currently working on a mobile app that is going to communicate with a RESTfull server over the HTTP-protocol. For this I have made a working code and got the communication working.

For the server to identify users I wanted to use cookies (some kind of sessions cookie). So I have started out with the two following helper-methods to create a HttpClient and a context (that includes my cookie).

// Gets a standard client - set to HTTP1.1
private HttpClient getClient() {
    HttpParams params = new BasicHttpParams();
    params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
    return new DefaultHttpClient(params);
}

// Gets the context with cookies to be used. This is to make each user unique
private HttpContext getHttpContext(String server) {
    CookieStore cookieStore = new BasicCookieStore();
    BasicClientCookie cookie = new BasicClientCookie("X-ANDROID-USER", "some name");
    cookie.setDomain(server);
    cookie.setPath("/");
    cookie.setVersion(1);

    cookieStore.addCookie(cookie);
    HttpContext localContext = new BasicHttpContext();
    localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
    return localContext;
}

I then connect to the server using the following (read function). That basically takes the Client and Conext generate by the last two helper methods and do a normal GET-request.
// Connects to the restfull server and returns the return value (get request)

    private String restfullRead(URI uri, String server)
    {
        // Sets up the different objects needed to read a HttpRequest
        HttpClient client = this.getClient();
        HttpGet request = new HttpGet();
        request.setURI(uri);
        HttpContext context = this.getHttpContext(server);

        // Connects to the server and reads response
        try {
          HttpResponse response = client.execute(request, context);
          reader.close();
        }
        catch (Exception e) {
        return "";
    }

When I run this to my server I get the following request.
GET /info/1 HTTP/1.1
Host: 192.168.0.191:8080
Connection: Keep-Alive

As you can see, this does not include any cookies. Thats why I wonder, why arent the cookie made in “getHttpContext” sent in the request?

  • 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-31T18:50:08+00:00Added an answer on May 31, 2026 at 6:50 pm

    This answer will help you:

    How do I make an http request using cookies on Android?

    // EDIT

    1.) Your Android app sends it’s unique NFC-Tag to the server.

    2.) The server create a new unique token and builds a releation beween the token and the NFC-Tag

    3.) Whenever your app is sending a request, send the unique NFC-Tag too.

    4.) The server will check the NFC-Tag and searchs the token and now your device is identified

    Sending custom header:

    HttpGet get = new HttpGet(getURL);
    get.addHeader("NFC", "YOUR NFC-TAG");
    get.addHeader("Some more header", "more infos");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently working on a cross-platform mobile app and have gone through the process
I'm currently working on a consumer mobile application project and have read that 40%
I'm currently working on a C# app targeted for Windows Mobile 6 devices that
I'm currently working in an app that shows a contact list to the user.
I'm currently porting an app that was written for Windows Mobile 2003 (compact framework
I am currently working on a mobile web page in asp.Net MVC2 that allows
I am working on a project that is a website, a mobile app, and
I'm working on a Qt mobile app for the symbian platform. I have a
Im currently working on a mobile web app and am wondering if I should
I'm currently working on a soft-input-panel for windows mobile and have run into a

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.