During the development process, forms often encounter errors and all information filled in when the page is returned is lost. to support page bounce, you can use either of the following methods. 1. use the header to set the Cache control header Cache-control. PHP code header (& amp; #39; Cache-control: p... "> <LINKhref =" http: // www. php1
During the development process, forms often encounter errors and all information filled in when the page is returned is lost. to support page bounce, you can use either of the following methods.
1. use the header to set the Cache control header Cache-control.
PHP code
- Header ('cache-control: private, must-revalidate'); // supports page jump back
2. use the session_cache_limiter method.
PHP code
- Session_cache_limiter ('private, must-revalidate'); // before session_start
The following describes the parameters of session_cache_limiter:
The meanings of several parameters in session_cache_limiter are as follows:
Nocache: of course, it is not cached (for example, the form information is cleared), but public variables can be cached.
Private: private cache (for example, the form information is retained but valid during the lifetime)
Private_no_cache: Private mode but not expired (form information is retained)
Publice: public (the form information is also retained)
Set the cache Expiration Time: Set the session_cache_expire function. the default value is 180 minutes.
Frequently encountered problems:
1. Session_cache_limiter ("private"); the form information is retained. However, if I modify the submitted information, the information displayed on the form page is still in the cache and cannot be automatically refreshed in time, if session_cache_limiter ("private") is not used, the form information cannot be retained.
Solution:
Before session_start, add
Session_cache_limiter ( "Private, Must-revalidate" );