2
\$\begingroup\$

So I'm using an external DLL with Unity to login to a web service and access functions from it.

The DLL works perfectly fine in a command prompt project, but when run in Unity I can log in successfully, but when I try to use any commands I get a session has expired error.

The DLL stores session cookies in the endpoint, so it appears that Unity isn't allowing this custom endpoint to store cookies.

Does anyone know how to make Unity allow custom endpoints to store cookies? Or where in an endpoint I could parse the cookie from so I could feed it in with any service commands?

For reference, here's a link to the main DLL, and here's a link to ContentService. The main DLL is compiled for .NET 3.5 so as to work with Unity.

Just as a reference, here's the exact error code I'm getting in Unity:

FaultException: Your session has expired.
System.ServiceModel.ClientRuntimeChannel.Request (System.ServiceModel.Description.OperationDescription od, System.Object[] parameters)
System.ServiceModel.ClientRuntimeChannel.DoProcess (System.Reflection.MethodBase method, System.String operationName, System.Object[] parameters)
System.ServiceModel.ClientRuntimeChannel.Process (System.Reflection.MethodBase method, System.String operationName, System.Object[] parameters)
\$\endgroup\$
1
\$\begingroup\$

I recommend using a tool, such as Chrome's Advanced REST client or WireShark to see what needs to be communicated to your server. There is a learning curve, but you will see both sides of the HTTP session.

\$\endgroup\$
0
\$\begingroup\$

I found these links to be helpful. The first describes how to deal with cookies. The second is a nice tutorial showing how to send login and registration data to a php-based web server. The tutorial focus on the client side, no info on what you have to do on the server side.

http://plyoung.wordpress.com/2011/08/05/unity-3d-and-session-cookies/

http://unity-tutorials.blogspot.com/

\$\endgroup\$
  • 1
    \$\begingroup\$ Link-only answers aren't the best; they lose their value entirely if the link goes away for any reason. It would be better if you also provided a brief summary of the solutions contained in the link (not just a description of what is at the link, which you've done). \$\endgroup\$ – Josh May 5 '14 at 15:27
  • \$\begingroup\$ Since I'm using a 3rd party web service I don't know exactly how to do web requests to it via Unity. I use the provided API to call the login function, I can do a WWWForm to the login address for the 3rd party web service but I'm not sure what the form field names are supposed to be. \$\endgroup\$ – Timothy Williams May 5 '14 at 16:39
  • \$\begingroup\$ The 3rd party API uses the SOAP interface, perhaps I could get a session cookie from there? I'm looking through all the source code for the API and there doesn't appear to be anywhere it's referencing a session cookie. I must just be missing something. \$\endgroup\$ – Timothy Williams May 5 '14 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.