Coldfusion sessions - how exactly CF identifies a connection / unique client
After some digging with the remote CFCs that I called from Word VBA, I found that they also established sessions. Which made me think and Googling (unsuccessfully) to explain how CF distinguishes different clients. I previously assumed that the browser cookie is configured to identify the client, but then here I consume the web service through a text application and still get the session variables and the sessionID set.
So, if I download and write to my application through a browser (chrome) and get to the test page, I get jsessionID = 123. If I run firefox and login, I get another jsessionid = 234, as expected. If I remove the remote cfc as a wsdl web service using Word VBA, I see that jsessionid = 345 is returned to the VBA module. If I close Word and open my macro again (containing a request to enter the web service), I get a new jsessionID = 567
So, what is it about the request that identifies the CF, and how it is stored during client identification?
This is the same issue in VBA HTTP call
Sub doHTTP()
Dim MyRequest As Object
Dim Val
httpString = "http://localhost:8888/test.cfm"
Set MyRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
MyRequest.Open "GET", httpString
' Send Request.
MyRequest.Send
MsgBox MyRequest.ResponseText
'now pass in the session urltoken we have just retreived
MyRequest.Open "GET", httpString & "?urltoken=" & MyRequest.ResponseText
' resend a request, this time with the urltoken.
MyRequest.Send
'take a look and see if the session variables are correct
MsgBox MyRequest.ResponseText
End Sub
in test.cfm
<cfif isdefined("URL.urltoken")>
<cfset session.urltoken="#URL.urltoken#">
<cfelse>
<cfset session.username="bob">
</cfif>
<cfoutput>session.urltoken="#session.urltoken#"</cfoutput><br>
<cfoutput>session.username="#session.username#"</cfoutput><br>
<cfoutput>session.sessionID="#session.sessionID#"</cfoutput>
Well, that works now, interestingly, I will need to remember a web service or HTTP calls that do not use a browser. I will need to pass the session id in the url manually.