question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to get session cookies to work

See original GitHub issue

I am trying to save some session data inside of a mutation. This is how I set the middleware and how I pass the session to the context.

const server = new GraphQLServer({
  context: (req: ContextParameters) => {
    return {
      session: req.request.session
    }
  },
  resolvers,
  typeDefs
})

server.express.use(session({
  cookie: {
    httpOnly: false
  },
  saveUninitialized: true,
  resave: false,
  secret: 'keyboard cat'
}))

I successfully add values to the session object… but later on they are not present on the next requests (I am using the playground). Is it a problem with my middleware configuration or something more? In a plain Express JS app this configurations is working correctly.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
alexneo2003commented, Sep 9, 2018

Hey, @schickling i’m forking auth example from examples with MongoDB modify (for DB and sessions via connect-mongo). after running it’s working perfect but when i’m upgrade graphql-yoga up to 1.16.2 v my server is stopped working as expected. signup/login - working fine isLogin (sessions) - don’t working (sessions in DB exists)

repo with my project can you check this out? pls

1reaction
alexneo2003commented, Sep 8, 2018

@giacomorebonato hey, bro. did you fix your problem? and how? i’m have same issues

Read more comments on GitHub >

github_iconTop Results From Across the Web

Turn cookies on or off - Computer - Google Account Help
Cookies save browsing information to make your online experience easier. Discover how to turn cookies on or off while using the Google Chrome...
Read more >
Can't seem to get session cookies working : r/webdev - Reddit
To check if browser is doing something for some reason you can open up (in chrome) dev tools, go to networking tab and...
Read more >
How to Fix - Failed to set session cookie. Maybe you are using ...
Step 2: Clear the Cookies from your browser ... Now go to your browser settings and clear the cookies from it. Navigate to...
Read more >
7 Keys to the Mystery of a Missing Cookie - Medium
Solution tip: Change the code where you are setting the cookie to set the Domain attribute accordingly. 6. Cookie Name is Prefixed with...
Read more >
Unable to get session cookies to work · Issue #156 - GitHub
I am trying to save some session data inside of a mutation. This is how I set the middleware and how I pass...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found