How to use cookie

Comprehensive cookie code examples:

How to use cookie.parse:

23
24
25
26
27
28
29
30
31
32
if (!socket.request.headers.cookie) {
	next(new Error("No cookie transmitted."));
	return;
}

let cookies = cookie.parse(socket.request.headers.cookie);

if (!cookies.sid) {
	next(new Error("No sid transmitted."));
	return;

How to use cookie.serialize:

878
879
880
881
882
883
884
885
886
887
888
889
890


  if (opts.path == null) {
    opts.path = '/';
  }


  this.append('Set-Cookie', cookie.serialize(name, String(val), opts));


  return this;
};