hapijs / hapijs/yar

Delete cookie as user logout

Open
#170 0 comments 0 reactions 0 assignees View on GitHub
support
Dominant language
JavaScript
Stars
132
Forks
59
PR merge metrics
No merged PRs in 30d

Description

### Runtime

Node

### Runtime version

v20.12.0

### Module version

11.0.2

### Used with

@hapi/boom, @hapi/cookie, @hapi/hapi, @hapi/inert, @hapi/vision

### Any other relevant information

I'm using `@hapi/cookie` for the authentication aid `@hapi/yar` for storing lots of information (e.g. three dozens objects with each having 40-50 properties). (Is it fine?)

### How can we help?

After successful login, I'm seeing two cookies in browser's Inspect Element > Application tab. One is for auth and second is for session. When I logout, I've written,

```js
const logout = async (request, h) => {
request.cookieAuth.clear();

return h.redirect("/auth/login");
};
```

This clear the cookie related to auth. But, not one that is used for session. How can I clear that as well? I've added

```js
request.yar.clear("fields");
```

as

```js
const logout = async (request, h) => {
request.cookieAuth.clear();
request.yar.clear("fields");

return h.redirect("/auth/login");
};
```

Here, `fields` is the name of session that I've used to save the fields for module. But, still not clearing.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.