当前位置:网站首页>网络安全——XSS之被我们忽视的Cookie
网络安全——XSS之被我们忽视的Cookie
2022-08-10 12:49:00 【InfoQ】
1.1 XSS 跨站脚本攻击介绍

1.2 XSS 跨站脚本攻击分类
1.3 Cookie 概述
(1、Cookie 概述:
(2、使用JavaScript 创建Cookie
(3、使用JavaScript读取Cookie
(4、使用JavaScript 修改Cookie
(5、Cookie字符串
(6、JavaScript Cookie 实例

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>js_cookie 实例</title>
</head>
<head>
<script>
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toGMTString();
document.cookie = cname + "=" + cvalue + "; " + expires;
}
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i].trim();
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
function checkCookie() {
var user = getCookie("username");
if (user != "") {
alert("欢迎 " + user + " 再次访问");
} else {
user = prompt("请输入你的名字:", "");
if (user != "" && user != null) {
setCookie("username", user, 30);
}
}
}
</script>
</head>
<body onload="checkCookie()"></body>
</html>


(7、Cookie的安全问题
- 1.Cookie欺骗
- 2.Flash的代码隐患
边栏推荐
- 2022-08-09:以下go语言代码输出什么?A:否,会 panic;B:是,能正确运行;C:不清楚,看投票结果。 package main import ( “fmt“ “syn
- BEVDet4D: Exploit Temporal Cues in Multi-camera 3D Object Detection 论文笔记
- 山水的高度
- M²BEV: Multi-Camera Joint 3D Detection and Segmentation with Unified Bird’s-Eye View Representation
- Shell:数组
- Jenkins修改端口号, jenkins容器修改默认端口号
- Polygon zkEVM工具——PIL和CIRCOM
- How to describe multiple paragraphs with different font settings in Open Office XML format
- 机器学习实战(2)——端到端的机器学习项目
- 想问下大佬们 ,cdc oracle初始化一张300万的表任务运行着后面就这个错 怎么解决哇
猜你喜欢
Code Casual Recording Notes_Dynamic Programming_70 Climbing Stairs
Basic knowledge of switches
Polygon zkEVM工具——PIL和CIRCOM
【黑马早报】雷军称低谷期曾想转行开酒吧;拜登正式签署芯片法案;软银二季度巨亏230亿美元;北京市消协约谈每日优鲜...
wirshark 常用操作及 tcp 三次握手过程实例分析
LeetCode中等题之搜索二维矩阵
来看Prada大秀吗?在元宇宙里那种!
Efficient and Robust 2D-to-BEV Representation Learning via Geometry-guided Kernel Transformer 论文笔记
关于flask中static_folder 和 static_url_path参数理解
ArcMAP出现-15的问题无法访问[Provide your license server administrator with the following information:Err-15]
随机推荐
神了!阿里数据库专家纯手写了这份604页的Oracle+MySQL攻坚指南
DNS欺骗-教程详解
shell:常用小工具(sort、uniq、tr、cut)
Redis上云迁移实践
娄底石油化工实验设计、建设规划概述
Drive IT Modernization with Low Code
I would like to ask the big guys, how to solve this error when cdc oracle initializes a 3 million table task running
没有接班人,格力只剩“明珠精选”
娄底疾控中心实验室设计理念说明
jenkins数据迁移和备份
表中存在多个索引问题? - 聚集索引,回表,覆盖索引
3DS MAX batch export file script MAXScript with interface
娄底污水处理厂实验室建设管理
OTA自动化测试解决方案---整体方案介绍
Prada, big show?In the yuan in the universe that!
Efficient and Robust 2D-to-BEV Representation Learning via Geometry-guided Kernel Transformer Paper Notes
Guidelines for Sending Overseas Mail (2)
生成树协议STP(Spanning Tree Protocol)
需要被记录的OpenStack相关的命令_自己用
山水的高度