Traditional Culture Encyclopedia - Weather inquiry - Php. After successfully setting cookies through ajax, will the client browser update cookie information? In other words, the web page does not refresh.

Php. After successfully setting cookies through ajax, will the client browser update cookie information? In other words, the web page does not refresh.

This will not be refreshed. After setting cookie through ajax, the setting result (success/failure) must be returned from the backend.

Then update the page through js at the front end.

Because the web page was downloaded when it was displayed, it will not change. If you need to change the content of the web page, you must use js to modify it, ajax to retrieve the data, and then the front end uses js to modify the page according to the data.

Your back-end deleted the cookie, but the front-end page has been parsed by the browser, so the browser will not modify the login information by itself.

Solution:

Ajax sends a request →PHP receives an exit request →PHP deletes a cookie→PHP returns a success code {"success": 1} or a failure code {"success":0}→ Front-end receives a return code → If it is 1, through js (such as document). GetElementByid ('user name'). Neller.

Generally, the exits are directly linked. After the user accesses the connection, the back end cleans the cookie, and then jumps to the original page or home page of 302 or 30 1. At present, most websites quit by jumping.

Although ajax does not refresh the page theoretically, the user experience is better, but personally, it is not necessary to use ajax for such operations as quitting the account. Usually, ajax is used for dynamically displayed data in web pages (such as weather, lottery results, activity participation information) and other data that need to be changed frequently.