js获取cookie信息
时间: 2024-04-02 17:27:56 浏览: 115
javascript 获取cookie
以下是两种JavaScript获取cookie信息的例子:
1. 获取所有cookie信息
```javascript
var cookies = document.cookie;
console.log(cookies);
```
2. 获取特定cookie信息
```javascript
var cookies = document.cookie;
var userId = cookies.match(/userId=(\d+)/)[1];
console.log(userId);
```
阅读全文