You can use HttpRequest.RemoveHeaders("Cookie") to remove all the cookies. This should be done after the request is created.
Hello,
Thanks for your reply.
I am looking at the HTTPJob file. I see as part of the
Sub Class_Globals
Public req As HttpRequest
Then further on down in PostBytes, req is initialized
I'm assuming the Header values for this request are inherited from some higher-level Android object. If I remove Header cookies from this request after it is initialized will it remove the cookie from this request but leave the cookie defined in the higher-level Android object – thereby not really removing the cookie?
If my assumption is true, I would maybe be better off keeping a local copy of the cookie value I want and then explicitly setting that value each time a req is initialized?
Or, is my assumption wrong and removing the cookie gets rid of the cookie for the current and all future requests?
Added Later:
I am having trouble using the HTTPRequest methods.
Here's code from my Main B4A file:
hd.Initialize // header Map
hd.Put("cookie", "PHPSESSID=changed")
httpJb.PostString(PostUrl, s, hd)
Here is code from the HttpJob file which I have modified to handle the header map:
Public Sub PostString(Link As String, Text As String, hd As Map)
PostBytes(Link, Text.GetBytes("UTF8"), hd)
End Sub
Public Sub PostBytes(Link As String, Data() As Byte, hd As Map)
mLink = Link
req.InitializePost2(Link, Data)
If (hd.Size > 0) Then
For i=0 To hd.Size-1
Log(hd.GetKeyAt(i))
Log(hd.GetValueAt(i))
req.RemoveHeaders(hd.GetKeyAt(i))
req.SetHeader(hd.GetKeyAt(i), hd.GetValueAt(i))
Next
End If
CallSubDelayed2(HttpUtils2Service, "SubmitJob", Me)
End Sub
Here is the corresponding output from the Log file:
And finally, here is debugger output from within my PHP IDE:
Cookie:
[PHPSESSID] changed, PHPSESSID=cmhlhgl25mne7ci876sjl7d897
From the debugger output in the PHP IDE you can see the value of the cookie PHPSESSID contains the original value preceded by my new value "changed".
I've tried every combination I can think of – changing character case, including or not including the RemoveHeader, exchanging "cookie" with "PHPSESSID", adding a colon, and many other things.
I cannot seem to get it to remove the original PHPSESSID cookie or header nor can I get it to change the original value with my new value of "changed".
What am I missing?
Thanks,
Barry.