search
Homephp教程php手册php history.back返回后表单数据丢失的解决办法 - small_123

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use