Q
Node.js
26
A
cevap
34
, okumak cookieParser
middleware ve req.cookies
kullanabilir ve res.cookie()
çerezleri yazmak için: Express 4.0, Connect will no longer be included with Express itibariyle
// configuration
app.use(express.cookieParser());
// or `express.cookieParser('secret')` for signed cookies
// routing
app.get('/foo', function (req, res) {
res.cookie('bar', 'baz');
// ...
});
app.get('/bar', function (req, res) {
res.send(req.cookies.bar);
});
[Güncelleme]
ve cookie-parser
dahil olmak üzere varsayılan ara katman have been moved into their own packages.
5
Çerezlerinizi ayarlamak için ifade edilen yanıt nesnesini kullanabilirsiniz.
+2
BU için gerekli değildir! Kesinlikle bu! Meslektaşım, "ekspres oturum yazma cookie" araması yapmak için çok fazla zaman harcadı ve Express’in dokümanlarını geçmeye çalışmadılar. – hjpotter92
İlgili konular
- 1. Node.js neden Node.js?
- 2. node.js
- 3. node.js
- 4. (node.js)
- 5. Node.js
- 6. Node.JS
- 7. node.js
- 8. node.js
- 9. node.js
- 10. Node.js:
- 11. node.js
- 12. Node.JS
- 13. node.js
- 14. Node.js
- 15. Node.JS
- 16. Node.js
- 17. node.js + request => node.js + bluebird + istek
- 18. nasıl node.js için hala çok yeniyim node.js
- 19. Web Services ve Node.js Çalışan Rolü/Node.js
- 20. Uint8Array'i node.js
- 21. Node.js res.render
- 22. Ekspres node.js
- 23. Node.js kitaplığı?
- 24. Node.js, Windows
- 25. node.js - jade
- 26. nasıl node.js
- 27. node.js REPL
- 28. Node.js rasgele bağlantı noktalarını nasıl seçer? Node.js ile
- 29. '>' node.js istemi Ben eshell içinde node.js çalıştırmak istediğiniz eshell
- 30. Node.js dağıtım sorunu
Ben aynı sorun var:
Sen o nasıl yapılacağına ilişkin ayrıntılı bilgi bulabilirsiniz. App.use (express.cookieParser()) 'i değiştirdiğimde; app.use ile (gerektirir ('connect'). cookieParser()); Set-Çerez vardır: currentId = b8RuviEVAytniu62; Yanıt Başlığında Ama req.cookies.currentId ile erişmeye çalıştığınızda undefined olsun. – Sysrq147
'cookie-parser' aslında 'res.cookie()' – grabantot