Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable cookies using sails js

Tags:

sails.js

I need to remove all cookies of sails js, but i didn't find documentation. The problem is that the authentication is with token and no with cookies however the cookie is generated when make a request to the server in sails js. I need disabled creation of cookies in sails. Thanks

like image 335
user3934417 Avatar asked Feb 12 '23 06:02

user3934417


2 Answers

You can disable sessions in Sails, that should disable cookies. Add the code below in your .sailsrc:

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

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

like image 127
leompeters Avatar answered Feb 15 '23 07:02

leompeters


Try this one, It works for me:

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');
like image 36
Premjeet Avatar answered Feb 15 '23 09:02

Premjeet