Skip to content

Commit 1bf6f84

Browse files
committed
cookie-parser
1 parent 0edd92d commit 1bf6f84

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2580,6 +2580,38 @@ app.post('/api/users', jsonParser, function (req, res) {
25802580
})
25812581
```
25822582

2583+
**2. cookie-parser**
2584+
2585+
A cookie is a piece of data that is sent to the client-side with a request and is stored on the client-side itself by the Web Browser the user is currently using.
2586+
2587+
The `cookie-parser` middleware\'s cookieParser function takes a `secret` string or array of strings as the first argument and an `options` object as the second argument.
2588+
2589+
**Installation**
2590+
2591+
```bash
2592+
npm install cookie-parser
2593+
```
2594+
2595+
*Example*:
2596+
2597+
```js
2598+
var express = require('express')
2599+
var cookieParser = require('cookie-parser')
2600+
2601+
var app = express()
2602+
app.use(cookieParser())
2603+
2604+
app.get('/', function (req, res) {
2605+
// Cookies that have not been signed
2606+
console.log('Cookies: ', req.cookies)
2607+
2608+
// Cookies that have been signed
2609+
console.log('Signed Cookies: ', req.signedCookies)
2610+
})
2611+
2612+
app.listen(3000)
2613+
```
2614+
25832615
<div align="right">
25842616
<b><a href="#">↥ back to top</a></b>
25852617
</div>

0 commit comments

Comments
 (0)