Comments (7)
Weird. Any idea what the issue is? Or perhaps can you provide instructions on how to reproduce the issue so I can dig in?
from cookie-parser.
Alright I run this first>>
res.cookie("BOAT_SECURITY", String(json.refresh_token));
I print using this>>
console.log("[COOKIES] " + JSON.stringify(req.cookies));
comes out with
[COOKIES] {"BOAT_SECURITY":"undefined"}
console.log(document.cookie)
comes out with
BOAT_SECURITY=(censored, but correct input)
(I use glitch.com for this)
from cookie-parser.
The fact that undefined is in quotes means to me that String(json.refresh_token) is undefined when you set the server. If you add console.dir(String(json.refresh_token))
next to to the set, what is printed?
from cookie-parser.
If i look at EditThisCookie it shows the correct input, but here you go:
'kWXqYfyzOTgCssLWPj34fKL718sW14'
^ correct input
from cookie-parser.
Strange thing is if i make another cookie, and set a value, it retains through printing
from cookie-parser.
Thanks! So here is my attempt to turn what you gave so far into something to reproduce the issue. Unfortunately as you can see it didn't reproduce the issue. Can you teak the code and / or instructions below to cause the issue to occur on my end?
- Install modules with
npm i cookie-parser express
- Create
app.js
with the following content:
const cookieParser = require('cookie-parser')
const express = require('express')
const app = express()
app.use(cookieParser())
app.get('/first', (req, res) => {
res.cookie('BOAT_SECURITY', 'kWXqYfyzOTgCssLWPj34fKL718sW14')
res.send('go to /second')
})
app.get('/second', (req, res) => {
console.log("[COOKIES] " + JSON.stringify(req.cookies))
res.send('check console')
})
app.listen(3000)
- Run
node app.js
- Open Chrome to
http://127.0.0.1:3000/first
- Open Chrome to
http://127.0.0.1:3000/second
- Observe the console output from
app.js
:
$ node app.js
[COOKIES] {"BOAT_SECURITY":"kWXqYfyzOTgCssLWPj34fKL718sW14"}
from cookie-parser.
I renamed the cookie and it works. Kinda weird though
from cookie-parser.
Related Issues (20)
- Cookie Parser not reading signed cookies HOT 2
- Reading duplicated cookies HOT 5
- Docs on signedCookie seem to be off HOT 1
- How to sign a cookie manually? HOT 1
- create and remove cookies HOT 1
- cookieParser.signedCookie seems to not work properly HOT 5
- How to change/set domain, seems impossible? HOT 1
- Cookies values with "j:" prefix should not be parsed as JSON by default HOT 4
- signedCookie is unlikely to be used correctly HOT 1
- How do I clear the cookie(s)? HOT 1
- Inaccurate docs about JSONCookie, JSONCookies, signedCookie and signedCookies HOT 3
- Clear Cookies Feature? HOT 1
- My cookies automatically expire after 30 minutes HOT 1
- Get Metadata from cookie HOT 1
- [ FEATURE ] Support for ES6 imports HOT 1
- Provide types for the cookies in typescript HOT 5
- cookie 0.5.0 HOT 2
- Cookies not setting in production HOT 5
- Node.js v20.9.0 fetch API can't get set-cookie header set by cookie-parser HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cookie-parser.