N
N
newaitix2017-07-09 09:51:47
Node.js
newaitix, 2017-07-09 09:51:47

Cookie nodejs how to set?

How to set a cookie in the user's browser?
the server looks like this

http.on('request',function(req,res){
  var nameFile=req.url.split('.').length==1?conf.get('htaccess')[req.url]:req.url,
    expansion=(nameFile||'').split('.'),
    existsFile=fs.existsSync('../site'+nameFile);
  res.writeHead(existsFile?200:404,{
    'Access-Control-Allow-Origin':'*',
    'Content-type':conf.get('contentType')[expansion[expansion.length-1]]+';charset=utf-8'
  });
  existsFile?
    res.end(fs.readFileSync('../site'+nameFile))
  :
    res.end('Page not Foud');
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RidgeA, 2017-07-09
@newaitix

Cookies is the same header.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question