http 安全

HSTS:

响应头中包含  

Strict-Transport-Security: max-age=31536000;

表示 使用http访问时, 要求浏览器强制转换为https 

当用户已经安全的登录开启过htst功能的网站 (支持hsts功能的站点会在响应头中插入:Strict-Transport-Security) 之后,支持htst的浏览器(比如chrome. firefox)会自动将这个域名加入到HSTS列表,下次即使用户使用http访问这个网站,支持htst功能的浏览器就会自动发送https请求(前提是用户没有清空缓存,如果清空了缓存第一次访问还是明文,后续浏览器接收到服务器响应头中的Strict-Transport-Security,就会把域名加入到hsts缓存中,然后才会在发送请求前将http内部转换成https),而不是先发送http,然后重定向到https,这样就能避免中途的302重定向URL被篡改。进一步提高通信的安全性。

chrome 浏览器 用Status Code:307 Internal Redirect 进行内部跳转

用户第一次访问服务器, 服务器回应302,

  用户跳转到https,  服务器回应 Strict-Transport-Security 头, 这个时候用的https信息是无法篡改的. 浏览器会将其加入到HSTS列表, 下次访问时就会强制转为https 

ref: http://www.freebuf.com/articles/web/66827.html

cookie:

 Set-Cookie: u_login=aaaaaaa; HttpOnly; path=/

  HttpOnly: 使此cookie禁止js获取, 开发者工具可以看到

原文地址:https://www.cnblogs.com/listenerln/p/9174174.html