I cannot create a cookie using the http plugin. My code looks like the one below:
plugins.http.setHttpClientCookie(“clientName”,“varName”,“Hello World”,null,null,-1,false)
The function returns false when executed.
Do I need to configure or call a method before I can set cookies?
Do you have an http client connection opened before setting the cookie?
If you don’t it’s like trying to set a cookie in your client’s browser without the browser actually opened
Cookies are set on a connection, they are the result of an exchange between a client and a server, the server places some info in the http header of its response to ask the client to store some information. If you use setHttpClientCookie when there’s no connection opened there is no exchange.
ptalbot:
Do you have an http client connection opened before setting the cookie?
If you don’t it’s like trying to set a cookie in your client’s browser without the browser actually opened
Cookies are set on a connection, they are the result of an exchange between a client and a server, the server places some info in the http header of its response to ask the client to store some information. If you use setHttpClientCookie when there’s no connection opened there is no exchange.
Thanks, Patrick, but how do you do it in Servoy framework?
I tried createHttpClient → getPageData → getHttpClientCookie → deleteHttpClient but no good. It still returns false.
ptalbot:
Did you set a cookie in a previous session? If not, I suppose getHttpClientCookie will return nothing.
Yes, I am also calling setHttpClientCookie in the same position where I am calling getHttpClientCookie function. The getPageData function returns an html web page so an http client has successfully been created. Did I miss out anything else?
Not that I can think of…
I have not used the http plugin to set cookies but I have used the Apache Http Client java library (the old and the new API) that the plugin is relying on over the years.
I will need to give it a try to better help and/or find out what’s going on, unless someone knows the answer already?