0 Replies Latest reply on Sep 18, 2007 3:23 AM by MartinW-2006

    Setting cookies in a webservice doesn't work

    MartinW-2006
      I am using a ColdFusion component to publish a web service and I want that web service to set a cookie. However, this does not appear to always work.

      Specifically, if I invoke the web service from the browser by entering a URL such as "service.cfc?method=name" in the address bar, then the cookie is set properly. If I use <cfinvoke> the cookie is not set. If I use the EasySoap C++ library then the cookie is set if I use <cfheader> to set it, but is not set if I use <cfcookie>.

      Please see the attached code samples. "cookies.cfc" is the component used to publish the web service, "cookies.cfm" is a simple test programme which invokes the web service either using <cfinvoke> or with the web browser (the second time you invoke the web service you should see that the cookies were set the last time you invoked it, but this only happens if you invoke it using the browser. A simple C++ programme to invoke the web service (using EasySoap, which in turn uses WinInet) returns "Cookie.EchoLast_2=99" meaning that only cookies set using <cfheader> are actually being set.

      Please explain what on earth it is doing and what is the correct/approved way of setting cookies in a web service.

      Thanks!