
Product
Introducing Historical Analytics – Now in Beta
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.
@candyjs/session-cookie
Advanced tools
基于 cookie 的 session
$ npm install @candyjs/session-cookie
入口文件配置
// index.js
const CandyJs = require('candyjs');
const App = require('candyjs/web/Application');
const Hook = require('candyjs/core/Hook');
const Session = require('@candyjs/session-cookie');
Hook.addHook(Session.start({
key: 'some secure strings',
// 毫秒
maxAge: 86400000
}));
new CandyJs(new App({
'id': 1,
'debug': true,
'appPath': __dirname + '/app'
})).listen(2333, function(){
console.log('listen on 2333');
});
使用
// IndexController.js
const Controller = require('candyjs/web/Controller');
class IndexController extends Controller {
run(req, res) {
let views = req.session.getAttribute('views');
if(undefined === views) {
views = 0;
} else {
views += 1;
}
req.session.setAttribute('views', views);
res.write('views: ' + views);
res.end();
}
}
session#getAttribute(name: string): any;
session#setAttribute(name: string, value: any): void;
session#deleteAttribute(name: string): void;
session#clear(): void;
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.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.
Product
Module Reachability filters out unreachable CVEs so you can focus on vulnerabilities that actually matter to your application.
Company News
Socket is bringing best-in-class reachability analysis into the platform — cutting false positives, accelerating triage, and cementing our place as the leader in software supply chain security.