You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've tried to look for a method to enumerate the sessions present on express using session-file-store. Seemingly there is a list method to do that. I've tried to access it like request.sessionStore.list() (Edit : which gives me a null value) and FileStore.prototype.list (with FileStore being a const holding the reference to the session-file-store object). The first doesn't work at all and the second raises a problem with the path attribute of options var (used inside helpers.list) being undefined. The general usage seems to be . If there is a better way to do this, It'd be greatly appreciated.
This is my code : app.get('/scores', cors(), (req, res) => { console.log(req.session) console.log(req.sessionStore.list((callbackVar) => { console.log(callbackVar) })) let sess_count = 0 console.log(FileStore.prototype.list(function session_count(a, len) { sess_count = len; console.log("Total active session count is " + sess_count); console.log("============"); }) ) }
<Code is not complete, only relevant sample is being passed>
Error produced when doing FileStore.prototype..list is : App starting index.js:226 Session {cookie: Cookie, name: '<something>', quizTimeObj: {…}, t1_score: {…}, t2_score: {…}} index.js:195 undefined index.js:196 null index.js:197 TypeError: Cannot read property 'path' of undefined at Object.list (c:\Users\<something>\Google Drive\projects\Quizzer\node_modules\session-file-store\lib\session-file-helpers.js:352:24) at Store.FileStore.list (c:\Users\<something>\Google Drive\projects\Quizzer\node_modules\session-file-store\lib\session-file-store.js:120:13) at c:\Users\<something>\Google Drive\projects\Quizzer\index.js:200:37 at Layer.handle [as handle_request] (c:\Users\<something>\Google Drive\projects\Quizzer\node_modules\express\lib\router\layer.js:95:5) at next (c:\Users\<something>\Google Drive\projects\Quizzer\node_modules\express\lib\router\route.js:137:13) at cors (c:\Users\<something>\Google Drive\projects\Quizzer\node_modules\cors\lib\index.js:188:7)
The text was updated successfully, but these errors were encountered:
Seems like my approach was flawed. The list method seems to function reasonably close to all() method from express-session. Using the get() method on the store then gives me the results. One thing that I noted was that the sessionID(s) all had a .json extension. Seemingly the get method then added a .json at the end and as a result it was .json.json which couldn't be found.
let sessStore = req.sessionStore;
let data = req.sessionStore.list((a, b) => {
if (a) {
console.error(a)
} else {
console.log(b)
console.log(sessStore)
let trueVal = b.map((cookieID) => {
console.log(cookieID.split('.')[0])
sessStore.get(cookieID.split('.')[0], (err, sess) => {
if (err) {
console.log(err)
} else {
console.log(sess)
return 0;
}
})
So the sample code that I am using right now strips the .json at the end before passing it to the get() method.
I'll wait a bit for the dev response before closing the issue to make sure that I'm not doing something wrong here
I've tried to look for a method to enumerate the sessions present on express using session-file-store. Seemingly there is a
list
method to do that. I've tried to access it likerequest.sessionStore.list()
(Edit : which gives me a null value) andFileStore.prototype.list
(with FileStore being a const holding the reference to the session-file-store object). The first doesn't work at all and the second raises a problem with the path attribute of options var (used inside helpers.list) being undefined. The general usage seems to be . If there is a better way to do this, It'd be greatly appreciated.This is my code :
app.get('/scores', cors(), (req, res) => { console.log(req.session) console.log(req.sessionStore.list((callbackVar) => { console.log(callbackVar) })) let sess_count = 0 console.log(FileStore.prototype.list(function session_count(a, len) { sess_count = len; console.log("Total active session count is " + sess_count); console.log("============"); }) ) }
<Code is not complete, only relevant sample is being passed>
Error produced when doing FileStore.prototype..list is :
App starting index.js:226 Session {cookie: Cookie, name: '<something>', quizTimeObj: {…}, t1_score: {…}, t2_score: {…}} index.js:195 undefined index.js:196 null index.js:197 TypeError: Cannot read property 'path' of undefined at Object.list (c:\Users\<something>\Google Drive\projects\Quizzer\node_modules\session-file-store\lib\session-file-helpers.js:352:24) at Store.FileStore.list (c:\Users\<something>\Google Drive\projects\Quizzer\node_modules\session-file-store\lib\session-file-store.js:120:13) at c:\Users\<something>\Google Drive\projects\Quizzer\index.js:200:37 at Layer.handle [as handle_request] (c:\Users\<something>\Google Drive\projects\Quizzer\node_modules\express\lib\router\layer.js:95:5) at next (c:\Users\<something>\Google Drive\projects\Quizzer\node_modules\express\lib\router\route.js:137:13) at cors (c:\Users\<something>\Google Drive\projects\Quizzer\node_modules\cors\lib\index.js:188:7)
The text was updated successfully, but these errors were encountered: