I would like to work with sessions on low level. How is it possible to generate session id in node.js?
It is not clear what you are trying to achieve, but... a session ID is just an ID! You generate it however you want. There are no requirements except for uniqueness. It is a good idea though to make it secure. For example this function may be your session id generator:
var crypto = require('crypto');
var generate_key = function() {
var sha = crypto.createHash('sha256');
sha.update(Math.random().toString());
return sha.digest('hex');
};
You call generate_key() and you check whether it exists in a database. If it does you call it again and so on and so on.