Home  >  Article  >  php教程  >  php history.back返回后表单数据丢失的解决办法 - small_123

php history.back返回后表单数据丢失的解决办法 - small_123

WBOY
WBOYOriginal
2016-05-20 10:14:301236browse

js使用history.back返回表单数据丢失的主要原因就是使用了session_start();的原因,该函数会强制当前页面不被缓存。本文章向码农介绍php history.back返回后表单数据丢失的解决办法,感兴趣的码农可以参考一下。

解决办法如下:

在你的 Session_start 函数后加入 header("Cache-control: private"); 注意在本行之前你的PHP程序不能有任何输出。

还有基于session的解决方法,在session_start前加上 

session_cache_limiter('nocache');// 清空表单 
session_cache_limiter('private'); //不清空表单,只在session生效期间 
session_cache_limiter('public'); //不清空表单,如同没使用session一般

 

原文地址:http://www.manongjc.com/article/823.html

相关阅读:

php $_PHP_SELF表单提交到当前页面的代码

php表单提交后返回表单数据丢失的解决办法

php结合js实现表单提交给多个页面的方法

php 表单提交到当前页实例

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn