How do I add cookie credentials to an AJAX request?

0 favourites
  • 5 posts
From the Asset Store
Customize the animation of character when item changed
  • I'm connecting to a host with ajax and get a response back. So far so good.

    I need to find a way to add credentials to my post to the cross domain server.

    The only thing i could find was that i need to add "xhr.withCredentials = true;" to my request, but I don't know how.

    Any help?

  • I'm connecting to a host with ajax and get a response back. So far so good.

    I need to find a way to add credentials to my post to the cross domain server.

    The only thing i could find was that i need to add "xhr.withCredentials = true;" to my request, but I don't know how.

    Any help?

    I have been looking to do this for ages. I want to set my own header so only my app can access those scripts but I'm still unsure on how to do this with PHP.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I'm not sure but it seems like the current AJAX plugin doesn't support it.

    The only thread I found involves modifying runtime for the AJAX plugin, but that's an old post for Construct 2.

    construct.net/en/forum/construct-2/how-do-i-18/send-ajax-request-cookies-133256

    Ashley Is this something that can be requested as a feature, or is it something that can be done, but I don't know how?

  • Does anyone know if scripting can be used to achieve what I want? Need to include the cookie data in future API calls after connected to host.

    I'd be happy to pay someone with the knowhow to help me out here :)

  • One solution I found is that might work is using this lib. I tried it out on a simple webpage and seems to be working so now going to test it from within Construct.

    github.com/axios/axios

    Which allows me to use xhr.withCredentials = true on requests to include the cookie data. Will be trying it out today and see if it helps. It should also work from node.js

    Ashley is it much work to the xhr.withCredentials = true option in the AJAX plugin? Is it possible to get better support for cross domain requests in the near future?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)