I wrote my server-side code prior to learning libGDX and writing my client-side code. Gdx.net provides for the http get communication I designed for, except for session authentication. I say that based on not finding sessions mentioned in the API, and a couple heavies confirming it on the libGDX discord.

Are there any libraries / examples out there of libGDX developers who mirrored session authentication functionality? The key limitation here is I want to stay with http request/response communication.

Minus any such direction, my next step will be to try using the "javax.servlet" libraries I used server-side on the client, and forgo the http classes that come included in the Gdx.net package. I'm reluctant to take this step noting that libGDX has its own versions of lots of classes, for efficiency and to prevent memory leaks given how libGDX programs execute. It'll be a while yet before my programming skills can detect and address such subtle issues. Also, I think that browsers and the server servlets run on participate in session architecture. With neither component in a libGDX PC app for "javax.servlet" to collaborate with, I'm doubtful this solution can work.

If it doesn't work, I'll think about moving up my goal of researching and learning how to use cloud hosting services. Some of these were recommended to me on discord as having frameworks with built-in support for authentication.


1 Answer 1


I learned more about what was going on under the covers in regards to sessions, namely that they manifest as cookies in the headers:

static String session = null;

public static void get(HashMap<String, String> parameters) {
    HttpRequest httpGet = new HttpRequest(HttpMethods.GET);
    if (session != null)   
        httpGet.setHeader("Cookie", session);

     Gdx.net.sendHttpRequest (httpGet, new HttpResponseListener() {

            public void handleHttpResponse(HttpResponse httpResponse) {

                String cookie = httpResponse.getHeader("Set-Cookie");
                if (cookie != null) {
                    String delims = "[;]+";
                    String[] tokens = cookie.split(delims);
                    session = tokens[0];
  • \$\begingroup\$ If this solved your problem, be sure to click the checkmark icon to mark this answer as "Accepted" \$\endgroup\$
    – DMGregory
    May 10, 2021 at 11:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .