NodeSession icon indicating copy to clipboard operation
NodeSession copied to clipboard

Documentaition is not noob friendly...

Open ghost opened this issue 4 years ago • 1 comments

I am trying to wrap my head around how to use this library and can't. I believe I am missing some common knowledge, so it is my fault, but throwing in a couple of links to give direction would probably help others like me. I don't even know what to look. Specifically I am stuck trying to understand how to re-attach the session to the request when it comes the second time.

ghost avatar Jan 08 '22 19:01 ghost

You have to do following step only once when you boot your application:

// init
session = new NodeSession({secret: 'Q3UBzdH9GEfiRCTKbi5MTPyChpzXLsTD'});

Then you just have to call session.startSession(req, res, callback) in an HTTP middleware for each request. If the session has already been initiated for a user it will be read a reattached by reading the details from cookies.

I hope now you are clear about what needs to be done.

harishanchu avatar Jan 11 '22 07:01 harishanchu