
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@fekit/mc-cookie
Advanced tools
一个操作 cookie 的常用方法。可以对 cookie 进行增删改查工作,并且可以单条或者批量操作。
http://fekit.cn/plugins/mc-cookie/
NPM:
npm i @fekit/mc-cookie
CDN:
<script type="text/javascript" src="https://cdn.fekit.cn/@fekit/mc-cookie/mc-cookie.umd.min.js"></script>
<script>
cookie.set({ key: 'aaa', val: 111 });
</script>
{
key : 'aaa', // 属性名
val : 'this is aaa; ', // 属性值
domain: '', // 域名(默认不设为当前页面域名,一般不用设置)
path : '', // 域名下子路经(默认不设,一般不用设置)
time : '+{1y1m11d1h1n1s}' // + 在现在开始算起的y年m月d日h时n分s秒后失效, 可以仅设置其中一个,比如1d=1天后失效
'2022-12-12 10:0:0' // 以字符串形式传入指定时间
1665367200000 // 转入时间戳
new Date('2022-12-22 10:0:0') // 直接传时间对象
}
设置一个属性:
// 引入插件文件,后面的示例略过
import cookie from '@fekit/mc-cookie';
cookie.set({
key: 'aaa',
val: 'aaa_111$222#333@444%555*666',
});
设置多个属性:
cookie.set([
{
key: 'bbb',
val: 'bbb_abc+123+中文+〜!#¥%……&*()',
time: '+{1d}', // 1天后失效
},
{
key: 'ccc',
val: 'ccc_abc+123+中文+〜!#¥%……&*()',
time: '+{2d5h30m}', // 2天5小时30分钟后失效
},
{
key: 'ddd',
val: 'ddd_abc+123+中文+〜!#¥%……&*()',
time: '2022-12-12', // 在2022年12月12日0点0分0秒失败
},
]);
获取一个属性:
let aaa = cookie.get('aaa');
console.log(aaa);
以数组形式获取多个属性:
let aList = cookie.get(['aaa', 'bbb', 'ccc']);
console.log(aList);
以对象形式获取多个属性:
let oList = cookie.get({ a: 'aaa', keyName: 'bbb', abc: 'ccc' });
console.log(oList);
获取全部属性并返回数组:
let all = cookie.all();
console.log(all);
另外一种方便灵活的用法:
let all = cookie.all();
// 我想获取aaa
console.log(all.aaa);
// 还需获取ccc
console.log(all.ccc);
删除一个属性:
cookie.del('aaa');
删除多个属性:
cookie.del(['aaa', 'bbb', 'ccc']);
删除全部属性:
cookie.del('*');
判断是否有某个属性:
let hasAAA = cookie.has('aaa');
console.log(hasAAA);
v2.1.1 [Latest version]
1. 优化time设置失效时间的入参,添加多种入参方式
v2.0.9
1. 修复package.json配置错误
v2.0.8
1. 修改了打包工具
2. 提供了esm和umd两种方式
如果您在使用中遇到问题,请通过以下方式联系我。
QQ: 860065202
EMAIL: xiaojunbo@126.com
FAQs
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.