diff --git a/example/test.ts b/example/test.ts index 42550a0..f2cc3cb 100644 --- a/example/test.ts +++ b/example/test.ts @@ -82,7 +82,7 @@ httpServer.get("/site", (_req, rep) => { httpServer.delete("/session", (req, _rep) => { const username = req.session.user as string ?? ""; if (username.length > 0) { - delete req.session.user; + req.sessionDestroy(); return { code: 200, message: "Logged out!", diff --git a/mod.ts b/mod.ts index dd59a30..544cb13 100644 --- a/mod.ts +++ b/mod.ts @@ -448,6 +448,10 @@ export class RouteRequest { } } + sessionDestroy(): void { + this.session = {}; + } + header(name: string): unknown { const matchingHeader = Array.from(this.headers.keys()).find((headerName) => headerName === name