0

I don't know how to access cookies at serverside so, I don't have tried anything yet

is there any method or any NPM package which will help to set or get cookies at server side?

Sanjaysinh Zala
  • 134
  • 2
  • 12
  • Possible duplicate of [How to set cookie in node js using express framework?](https://stackoverflow.com/questions/16209145/how-to-set-cookie-in-node-js-using-express-framework) and [Set a cookie value in Node.js](https://stackoverflow.com/questions/12240274) – adiga Dec 24 '18 at 05:20
  • [How much research effort is expected of Stack Overflow users?](https://meta.stackoverflow.com/a/261593/3082296) – adiga Dec 24 '18 at 05:22

2 Answers2

3

You can use this package to manage cookies https://www.npmjs.com/package/cookies.

Here is a minimal example

var http = require('http')
var Cookies = require('cookies')

// Create a cookies object
var cookies = new Cookies(req, res, { keys: keys });
// Set the cookie to a value
  cookies.set('LastVisit', new Date().toISOString(), { signed: true })
shamon shamsudeen
  • 5,466
  • 17
  • 64
  • 129
0

Trigger an event from server to the client. The client will retrieve the cookie data and POST it back to the server. Vice-Versa for setting the cookie.

ellipsis
  • 12,049
  • 2
  • 17
  • 33