How to disable cookies using sails js

I need to delete all sails js cookies but I couldn't find any documentation. The problem is that authentication is done with a token and not with cookies, however the cookie is generated when making a request to the server in js sails. I need to disable the creation of cookies in sails. thank

+3


source to share


4 answers


You can disable sessions in Sails to disable cookies. Add below code to .sailsrc

:

{
  ...
  "hooks": {
    "session": false
  }
}

      



Source: http://sailsjs.org/documentation/reference/configuration/sails-config-session#?disabling-sessions

+2


source


Have you looked into this issue on github?

https://github.com/balderdashy/sails/issues/841



You can implement what sgress454

suggested in the comments on the thread to get rid of cookies - you may also need to uninstall some middleware like session

.

0


source


delete req.cookies.rememberme 

      

Will not work with sessions.

You can replace it with null :

res.cookie('rememberme', null);

      

Then check if the cookie is not null

0


source


Try the following:

**// Set Cookie**

res.cookie('cookieName', "cookieValue", { expires: new Date(Date.now() + 300000), httpOnly: true, signed: true });

**// Get Cookie**

req.signedCookies.cookieName;

**// Delete Cookie**

res.clearCookie('cookieName');

      

0


source







All Articles