Git Product home page Git Product logo

Comments (7)

dougwilson avatar dougwilson commented on April 28, 2024

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.

 avatar commented on April 28, 2024

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.

dougwilson avatar dougwilson commented on April 28, 2024

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.

 avatar commented on April 28, 2024

If i look at EditThisCookie it shows the correct input, but here you go:
'kWXqYfyzOTgCssLWPj34fKL718sW14'
^ correct input

from cookie-parser.

 avatar commented on April 28, 2024

Strange thing is if i make another cookie, and set a value, it retains through printing

from cookie-parser.

dougwilson avatar dougwilson commented on April 28, 2024

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?

  1. Install modules with npm i cookie-parser express
  2. 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)
  1. Run node app.js
  2. Open Chrome to http://127.0.0.1:3000/first
  3. Open Chrome to http://127.0.0.1:3000/second
  4. Observe the console output from app.js:
$ node app.js
[COOKIES] {"BOAT_SECURITY":"kWXqYfyzOTgCssLWPj34fKL718sW14"}

from cookie-parser.

 avatar commented on April 28, 2024

I renamed the cookie and it works. Kinda weird though

from cookie-parser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.