I am making a website (named webA) using nodejs. I want to be able to automatically log in another website (name webB) each time I access webA.
I searched at Google and realized that I need to use cookies to this? My code is now like below:
var cookie = require('cookie');
var escapeHtml = require('escape-html');
var http = require('http');
var url = require('url');
function onRequest(req, res) {
var cookies = cookie.parse(req.headers.cookie || '');
cookies.name = 'user_abcd';
cookies.password = '1234';
//post a request to webB ???
}
http.createServer(onRequest).listen(3000);
If I understand correctly, I guess I will need to 'construct' a request using the cookies I made, then send a post request to webB. Am I on the right track? Any codes will be highly appreciated.