iwillwen / webjs

Simple and stable development for Node.js
http://iwillwen.github.com/webjs
99 stars 13 forks source link

增加了session支持 #3

Closed leizongmin closed 13 years ago

leizongmin commented 13 years ago

测试代码:

var web = require('webjs');

var get = {
    '/':    function (req, res) {
        // 开启session
        req.sessionStart();

        // 计数器,用于测试Session数据
        if (isNaN(req.session.count))
            req.session.count = 0;
        req.session.count ++;

        res.end('session id=' + req.session_id + '\r\ncount=' + req.session.count);
    },
    'end':  function (req, res) {
        // 清空session
        req.sessionEnd();
        res.end('session end.');
    }
}

web.run()
    .get(get);
iwillwen commented 13 years ago

Thanks~