MCPcopy Create free account
hub / github.com/socketstream/socketstream / getSession

Function getSession

lib/session/memory.js:172–195  ·  view source on GitHub ↗

* Get session from the store. * @private

(sessions, sessionId)

Source from the content-addressed store, hash-verified

170 */
171
172function getSession(sessions, sessionId) {
173 var sess = sessions[sessionId]
174
175 if (!sess) {
176 debug('no session in MemoryStore for %s',sessionId);
177 return;
178 }
179
180 // parse
181 sess = JSON.parse(sess)
182
183 var expires = typeof sess.cookie.expires === 'string' ?
184 new Date(sess.cookie.expires) :
185 sess.cookie.expires
186
187 // destroy expired session
188 if (expires && expires <= Date.now()) {
189 debug('Session %s is Expired in MemoryStore',sessionId);
190 delete sessions[sessionId];
191 return;
192 }
193
194 return sess
195}

Callers 1

memory.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected