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
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
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
.
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
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');