PHP Session添加标题Pragma:no-cache

时间:2016-10-29 14:43:01

标签: php session http-headers

嗨大家好,我对http标头请求有疑问,当我测试标题时我得到了这个回复

HTTP/1.1 200 OK
Date: Sat, 29 Oct 2016 14:24:31 GMT
Server: Apache
X-Powered-By: PHP/5.6.27
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
Set-Cookie: PHPSESSID=2d17992cfbd621c51eca940df478b89a; path=/
Vary: Accept-Encoding,User-Agent
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Security-Policy: allow 'self';
X-Content-Type-Options: nosniff
Cache-Control: max-age=604800, must-revalidate
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8
Content-Language: it-it

只有在页面上有session_start()

时才会出现此部分
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-
    check=0
Pragma: no-cache

在干净的页面.php或.html页面上,我得到了回复

  HTTP/1.1 200 OK
    Date: Sat, 29 Oct 2016 14:34:27 GMT
    Server: Apache
    Last-Modified: Sat, 29 Oct 2016 13:15:00 GMT
    Accept-Ranges: bytes
    Content-Length: 314
    Vary: Accept-Encoding,User-Agent
    Cache-Control: max-age=604800, must-revalidate
    Expires: Sat, 29 Oct 2016 14:34:27 GMT
    X-Frame-Options: SAMEORIGIN
    X-XSS-Protection: 1; mode=block
    X-Content-Security-Policy: allow 'self';
    X-Content-Type-Options: nosniff
    Connection: close
    Content-Type: text/html; charset=UTF-8
    Content-Language: it-it

我尝试搜索evrywhere但不知道我是谁 Sombody知道为什么session_start();添加

Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-
    check=0
Pragma: no-cache
http标题中的

1 个答案:

答案 0 :(得分:3)

http://php.net/manual/en/function.session-cache-limiter.php

session_cache_limiter('private_no_expire:');
session_start();