I use nowjs and have an issue with sessions. here is the code:
now.on('connect', function(){
if(this.user.session){
this.user.session.views++;
console.log(this.user.session.views);
}
});
app.get('/', function(req, res){
var body = '';
body = body+' <script src="/nowjs/now.js"></script>';
if (req.session.views) {
++req.session.views;
} else {
req.session.views = 1;
body += '<p>First time visiting? view this page in several browsers :)</p>';
}
res.send(body + '<p>viewed <strong>' + req.session.views + '</strong> times.</p>');
console.log("body");
});
no the problem is that I can write anything into "this.user.session" but on next call everything is erased. in my example it counts how many times you have entered the site. and "views" is increasing by one each time, but it should be increasing by 2 because I of "this.user.session.views++;". I'm missing something or it can't be done?
if you have some examples of nowjs+sessions post is please thank you
I was using nowjs with sessions and Passport for authentication... I wrote a simple gist for making them work together ...