V
V
Vladimir Shiklgruber2015-06-23 02:06:05
PHP
Vladimir Shiklgruber, 2015-06-23 02:06:05

Should I use json?

Hello. I do Api for everything at once :) (in the Ajax browser on client devices)
There is an authorization check.
If the user is authorized, it displays yes; if not, it displays no.
In js I do something like this :)

$.ajax({
    type: "POST",
    url: "/api/reg/ssesid.php",
    data: $('#logform').serialize(),
    traditional: true,
    success: function(resp) {
      if (resp == 'yes') {
        location="/game/index.html";
      } else if (resp == 'no') {
      } else alert(resp);
    },
    error: function(resp) {
      alert('error');
    }
  });

Come on. Me interests and how I will check authorization on clients? As far as I understand, there is no support for cookies, and the API should not be platform dependent. Be it a browser or a client. Thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-06-23
@aaadddminnn

Should I use json?

Why not? Of course you can also use protobuf...
In general, this is not a problem to add, but it only makes sense for web applications (with certain reservations, if in your case the probability of XSS is higher than csrf vulnerabilities).
In general, a popular practice is JWT (JSON Web Tokens)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question