Example:
var sessions = require('sessions');
function load_session(req) {
sessions.load(sid);
}
Now that the session is loaded for a session id, how do I pass this session to another module in terms of best practices?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I usually see sessions just being handled like a singleton. You just use the fully qualified name of the session object and use it directly.
If you’re writing tests which need to mock the session, you could always provide a different load_session method which creates a mock version of the session object instead.