Skip to content

Instantly share code, notes, and snippets.

@santiago
Created June 7, 2011 13:32
Show Gist options
  • Save santiago/1012261 to your computer and use it in GitHub Desktop.
Save santiago/1012261 to your computer and use it in GitHub Desktop.
var app = module.exports = express.createServer();
app.set('view engine', 'jade');
app.configure(function(){
app.use(express.bodyParser());
app.use(express.cookieParser());
app.use(express.session({ secret: "a1b2c3d4e5f60000000000000" }));
});
app.post('/location', function(req, res){
var lat= req.body.location.lat;
var lon= req.body.location.lon;
var updated_at= new Date();
console.log(req.session);
if (!req.session.host) {
Host.create({lat:lat, lon:lon}, function(host) {
req.session.host= host.id;
console.log(req.session.host);
});
} else {
Host.find(req.session.host, function(host) {
Host.update(host, {loc:[lat,lon], updated_at:updated_at}, function(uhost) {
console.log("Updated client "+req.session.host);
console.log(host);
});
});
}
res.send("ok");
});
@santiago
Copy link
Author

santiago commented Jun 7, 2011

Here's what's outputting console.log(req.session)

{ lastAccess: 1307452842993,
cookie:
{ path: '/',
httpOnly: true,
_expires: Tue, 07 Jun 2011 17:20:42 GMT,
originalMaxAge: 14400000 } }
4dee25ab69f1552b74000001

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment