68
79

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

session_start()→POST遷移→戻る→有効期限切れ を防ぐ

Posted at

session_start() → POST遷移 → history.back 等で戻ると「有効期限切れ」って出てしまうのは、session_start()時に以下ヘッダが勝手に出力されてクライアントキャッシュが無効になってしまうため。

Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache

なので、session_start()直後に以下ヘッダを吐いてあげればOK。

<?php
session_start();
header('Expires: -1');
header('Cache-Control:');
header('Pragma:');
// 以下処理
68
79
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
68
79

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?