Skip to content

Delete cookie as user logout #170

@chauhankiran

Description

@chauhankiran

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,

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

request.yar.clear("fields");

as

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    supportQuestions, discussions, and general support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions