php - API with external generated session ID


I have an issue with an API I'm trying to call and the initialisation method.

The API requires;

Initialisation - Request a PHPSESSIONID from the API which is valid for 24 hours.

For every call you make, you generate a hash based on the session id, the call you make, and a API key.

Now, I got the initialisation working for one instance, but every time I refresh the page, I get a new PHPSessionID back from the API.

So in my thinking pattern I'd need;

  1. Do initialisation only once - Save the returned SESSIONID
  2. In every API call, generate hash based on SESSIONID
  3. If API call fails due to invalid SESSIONID, redo step 1

Any help on how to set this kinda thing up? Getting lost here.




Without knowing the full details of your application or the API it is a little hard to answer.

RESTful api's are stateless and shouldn't have a session, if this particular API creates a session for 24 hours, then I guess it comes down to how your application works.

If you only want to know about the API session while your user has a session on your application, then you could store the API's PHPSESSIONID (or the hash) in the users session so that you can use it until the session expires.

People are also looking for solutions to the problem: php - How to find rows in a MySQL database that don't correlate correctly with other rows


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.