I am creating an API that will use JSON. The main use of this API will be AJAX in the browser, but it can also be used by PHP scripts on the server side, etc.
There are two ways to do this (I think):
- Create an API so that it uses HTTP headers to set a session cookie and retrieves all data to save state with
COOKIE['session_id'](pseudo-code) - Create an API so that it returns
session_idand allows the user JavaScript to set its own cookie forsession_id
I lost a bit at all. Which method will be more secure (CSRF, etc.), which is easy for developers to understand, is easier to make changes on the server side without telling users that they need to update their code.
Also, do you recommend using the JSON-RPC specification, and if so, does one of these methods better support JSON-RPC?
Any help is greatly appreciated.
source
share