php session header,PHP启用session后对 HTTP Header 响应头的影响

PHP启用session后对响应头的影响

PHP启用session后,将会给响应头加上如下的http header

Expires: Thu, 19 Nov 1981 08:52:00 GMT

Cache-Control: no-store, no-cache, must-revalidate

Pragma: no-cache

准备示例代码 "session.php" :

session_start();

echo "hello world: has session" . PHP_EOL;

准备示例代码 "nosession.php"

echo "hello world: no session" . PHP_EOL;

通过PHP命令行 php -S 127.0.0.1:9999 启用临时server。

test@test:~/html$ ls

favicon.ico index.php nosession.php session.php

test@test:~/html$ php -S 127.0.0.1:9999

PHP 7.0.32-0ubuntu0.16.04.1 Development Server started at Thu Feb 21 20:57:07 2019

Listening on http://127.0.0.1:9999

Document root is /home/test/html

Press Ctrl-C to quit.

请求结果:

请求启用session的接口结果如下

test@test:~$ curl -i "http://127.0.0.1:9999/session.php"

HTTP/1.1 200 OK

Host: 127.0.0.1:9999

Connection: close

X-Powered-By: PHP/7.0.32-0ubuntu0.16.04.1

Set-Cookie: PHPSESSID=6htonb74ku0cvnu8vvkobkug92; path=/

Expires: Thu, 19 Nov 1981 08:52:00 GMT

Cache-Control: no-store, no-cache, must-revalidate

Pragma: no-cache

Content-type: text/html; charset=UTF-8

hello world: has session

test@test:~$

请求没有启用的session的接口的结果如下

test@test:~$ curl -i "http://127.0.0.1:9999/nosession.php"

HTTP/1.1 200 OK

Host: 127.0.0.1:9999

Connection: close

X-Powered-By: PHP/7.0.32-0ubuntu0.16.04.1

Content-type: text/html; charset=UTF-8

hello world: no session

test@test:~$

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值