Can an AJAX response set a cookie? If not, what is my alternative solution? Should I set it with Javascript or something similar?
转载于:https://stackoverflow.com/questions/3340797/can-an-ajax-response-set-a-cookie
Can an AJAX response set a cookie? If not, what is my alternative solution? Should I set it with Javascript or something similar?
转载于:https://stackoverflow.com/questions/3340797/can-an-ajax-response-set-a-cookie
Yes, you can set cookie in the AJAX request in the server-side code just as you'd do for a normal request since the server cannot differentiate between a normal request or an AJAX request.
AJAX requests are just a special way of requesting to server, the server will need to respond back as in any HTTP request. In the response of the request you can add cookies.