How Do I Generate A Valid Cookie

Viewed 276

Using Postman, I can create an API call which creates a TWEx2 cookie and auth. The cookie will look something similar to this:

83df910f-86a0-4ce8-a334-696d8g0f07db

Obviously, in my production code I cannot use Postman, so I have been trying to find a way to generate these cookies on my own. But when I try to search for "TWEx2 Cookie", or any kind of generator, I find tons of recipes for Twix Cookies. Clearly that's less than helpful.

Below you will see the TWEx2 cookie, and the auth. I have found that the auth is not needed, but the cookie is. I have tried several methods without the cookie, and the API request results in NULL.

enter image description here

Can anyone point me in the right direction on some instructions on how to create these hashed strings, or explain it to me?

1 Answers

The problem was my headers - I thought that I had accepted all returned values from the API but I had left out 'CURLOPT_HEADER' from my cURL.

Without receiving a cookie from the API, I had assumed (incorrectly) that I needed to create my own cookie. As soon as I added that in the header, I was able to see the cookie which was generated and returned by the API and use that.

So, if you run into this problem, make sure your headers are correct.

As a side note, "TWEx2" appears to be something specific to this API. It does not appear to be a normal thing.

Related