diff options
| author | Mhykol <mchaeldonald62@pm.me> | 2024-10-13 03:23:29 -0400 |
|---|---|---|
| committer | Mhykol <mchaeldonald62@pm.me> | 2024-10-13 03:23:29 -0400 |
| commit | 94a1189d8becec42ed0d949b3d441e5006bf68d9 (patch) | |
| tree | 2617bdbe1bb26175820d117f1798773d13adf8b1 | |
| parent | 611aa084110b24dc00757bc02f647f1675df8dda (diff) | |
Fixed sessions
| -rw-r--r-- | app.js | 3 | ||||
| -rw-r--r-- | source/session.js | 5 |
2 files changed, 6 insertions, 2 deletions
@@ -186,9 +186,10 @@ class App { } #ValidateCookie(req, res, next) { const { cookies } = req - session().Expired() if ('session_id' in cookies) { if (session().Exists(cookies.session_id.replace('session_id', ''))) { + session().Expired() + } else { res.clearCookie('session_id') res.cookie('session_id', session().Create()) } diff --git a/source/session.js b/source/session.js index 5846271..40d0563 100644 --- a/source/session.js +++ b/source/session.js @@ -13,7 +13,10 @@ class Session { sessions.set(object.result, Date.now() + (1000 * 60 * 60)) return object.result } - Exists(x) {return sessions.has(x)} + Exists(x) { + sessions.set(x, Date.now() + (1000 * 60 * 60)) + return sessions.has(x) + } Expired() {sessions.forEach((value, key) => {if (Date.now() > value) sessions.delete(key)})} } |
