VPS侦探论坛

 找回密码
 注册
查看: 2897|回复: 3

咨询下,lnmp,如何设置cookie为httponly,防止xss攻击

[复制链接]
发表于 2021-12-23 17:32:58 | 显示全部楼层 |阅读模式

大家好,请教下,lnmp,如何php设置cookie为httponly,主要是防止xss攻击
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2021-12-23 19:47:23 | 显示全部楼层


add_header  Set-Cookie  "HttpOnly";

添加至对应虚拟主机的server 段中,重启nginx
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2021-12-30 20:02:55 | 显示全部楼层

licess 发表于 2021-12-23 19:47
add_header  Set-Cookie  "HttpOnly";

添加至对应虚拟主机的server 段中,重启nginx

Nginx 1.21.5报错不认识这个语句!
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2021-12-31 08:53:41 | 显示全部楼层



明月登楼 发表于 2021-12-30 20:02
Nginx 1.21.5报错不认识这个语句!

放错位置了吧,nginx 0.3x左右的版本就已经支持add_header了
提示你的错误信息应该是:
"add_header" directive is not allowed here
具体可以看官网文档:http://nginx.org/en/docs/http/ng ... ule.html#add_header
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-20 17:50 , Processed in 0.025770 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表