OkHTTP how to use session (ANDROID)

I am using okhttp to access my webpage. The first time I access the session variable on the server, it is established that I am logged in. Then I want to access another part of the site that only works if I am logged in. It works in the browser, but it doesn't work with okhttp, i.e.

Example:

digit / index.php action = login &? = newun & = ÈÛ

If un and pw are correct, the session variable on the php script is set for login.

Further:

My application needs to do some things now that I am logged in, so

http: //digit/index.php? action = getDates

This should return a list of dates available to the user if I'm logged in.

In a web browser, it works. This means the session stays between both pages, I log in, and the second page I need to log in works.

Ultimately my problem is this:

new DownloadImageTask().execute("http://digit/index.php?action=login&name=unpow&pw=unpow");

      

Returns the input.

Then I go to this site:

new DownloadImageTask().execute("http://digit/index.php?action=registerDate&dateid=2");

      

Error: not logged in.

Here's my DownloadImageTask

        private class DownloadImageTask extends AsyncTask<String, String, String> {

    /** The system calls this to perform work in a worker thread and
     * delivers it the parameters given to AsyncTask.execute() */
    private String result;

    protected String doInBackground(String... urls) {

            Request request = new Request.Builder()
                    .url(urls[0])
                    .build();
            try {
                Response response = client.newCall(request).execute();
                big = response.body().string();
                publishProgress(big);
            } catch (IOException e) {
            }
        return big;
    }

    protected void onProgressUpdate(String ok)
    {
    }
    /** The system calls this to perform work in the UI thread and delivers
     * the result from doInBackground() */
    protected void onPostExecute(String result) {
        big = result;
        UpdateUI();
    }
}

      

+3


source to share





All Articles