1. The request code for $.getJSON is shown in Figure 1.0.

2. Inspecting the network, I found that a new PHPSESSID was generated in the response Cookie, as shown in Figure 1.1.

3. Add &callback=? to the request URL in $.getJSON, which is equivalent to setting the request format to jsonp, as shown in Figure 1.2.

4. Inspecting the network, I found that the request Cookie was already consistent with the current URL, as shown in Figure 1.3.

5. The POST request under $.ajax, with the code shown in Figure 2.0.

6. Inspecting the network, I found that a new PHPSESSID was generated in the response Cookie, as shown in Figure 2.1.

7. JS code implementation: dataType:’jsonp’,crossDomain: true, as shown in Figure 2.2.

8. Inspecting the network, I found that the request Cookie was already consistent with the current URL, but the POST request had been converted to a GET request, as shown in Figure 2.3.

9. JS code implementation: dataType:’json’,xhrFields:{withCredentials:true},crossDomain: true, as shown in Figure 2.4.

10. PHP code implementation:
header(“Access-Control-Allow-Credentials: true”);
header(“Access-Control-Allow-Origin: ” . C(‘wap_site_url’) . “”);
Where the value of C(‘wap_site_url’) is: http://mall.m.ygt.cm, as shown in Figure 2.5.

header(“Access-Control-Allow-Credentials: true”);
header(“Access-Control-Allow-Origin: ” . C(‘wap_site_url’) . “”);
Where the value of C(‘wap_site_url’) is: http://mall.m.ygt.cm, as shown in Figure 2.5
11. Inspecting the network, I found that the request Cookie was already consistent with the current URL, as shown in Figure 2.6.

12. JS code implementation for document.cookie: domain=.ygt.cm; as shown in Figure 2.7.

13. The POST request under $.ajax, with the code shown in Figure 3.0, using the jsonp format; in fact, you can also adopt the same handling approach as for the POST request under $.ajax, using the json format and then setting xhrFields.
