Android Question Insert a cookie using HTTPJob.GetRequest.SetHeader

Discussion in 'Android Questions' started by lentunti, Jul 9, 2015.

  1. lentunti

    lentunti Member Licensed User

    Hi all,

    Is it possible to use HTTPJob.GetRequest.SetHeader to replicate a cookie like this one in CookieManager:-

    CookieManager1.SetCookie("", "NWTABLETGATEWAYSESSION=lg9f3d66b04k77dfusek9bmfl5")

    I have to apply to to a HttpJob.download2 as opposed to a WebView.

    Is this possible?

    I have tried
    HTTPJob.GetRequest.SetHeader("SET-COOKIE", "NWTABLETGATEWAYSESSION=lg9f3d66b04k77dfusek9bmfl5; path=")
    but it doesn't seem to work

    Thanks for any help.

  2. sonicmayne

    sonicmayne Member Licensed User

  3. Erel

    Erel Administrator Staff Member Licensed User

    You need to set "Cookie" not "Set-Cookie". Set-Cookie header is used by the server (in the response) to ask the browser to set the cookies.
  4. lentunti

    lentunti Member Licensed User

    This is now my code :-
    getJobs.download2("", Array As String ("action", JSONstring))
    getJobs.GetRequest.SetHeader("Cookie", "NWTABLETGATEWAYSESSION=lg9f3d66b04k77dfusek9bmfl5; path=")

    Which now gives me an internal server error. Your you say that thus suggests that the cookie has worked but there is a problem on the server (Possible dumb question).

    thanks for your help.

  5. Erel

    Erel Administrator Staff Member Licensed User

    Note that cookies are managed automatically by HttpUtils2 (actually HttpClient). If the server has previously returned this cookie then you do not need to manually add it to the request.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice