# Having trouble trying to include cookies in Apollo Sandbox

**URL:** <https://community.apollographql.com/t/having-trouble-trying-to-include-cookies-in-apollo-sandbox/5606>\
**Category:** Server\
**Tags:** server\
**Created:** [January 30, 2023, 9:57pm UTC](https://community.apollographql.com/t/having-trouble-trying-to-include-cookies-in-apollo-sandbox/5606 "2023-01-30T21:57:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Uncasted](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/uncasted/32/4456_2.png) [@Uncasted](https://community.apollographql.com/u/Uncasted)\
**Post date:** [January 30, 2023, 9:57pm UTC](https://community.apollographql.com/t/having-trouble-trying-to-include-cookies-in-apollo-sandbox/5606/1 "2023-01-30T21:57:13Z")

</div>

Hello, I’m trying to include a cookie in my requests, I’ve tried to troubleshoot it by following some of the things I found in this forum and GitHub, but so far I’ve been unsuccessful. If anybody can help my with this I would appreciate it.

Here’s the code for my index.ts file:

```typescript
import { MikroORM } from "@mikro-orm/postgresql"
import { ApolloServer } from "apollo-server-express"
import connectRedis from "connect-redis"
import dotenv from "dotenv"
import express from "express"
import session from "express-session"
import { createClient } from "redis"
import "reflect-metadata"
import { buildSchema } from "type-graphql"
import { __prod__ } from "./constants"
import mikroConfig from "./mikro-orm.config"
import { PostResolver } from "./resolvers/post"
import { UserResolver } from "./resolvers/user"
import { ApolloContext } from "./types"

async function main() {
  dotenv.config()
  const orm = await MikroORM.init(mikroConfig)
  const emFork = orm.em.fork()
  await orm.getMigrator().up()
  const app = express()

  const corsOptions = {
    credentials: true,
    origin: "https://studio.apollographql.com",
  }

  app.set("trust proxy", ! __prod__ )

  const RedisStore = connectRedis(session)
  const redisClient = createClient({ legacyMode: true })
  redisClient.connect().catch(console.error)

  app.use(
    session({
      name: "qid",
      store: new RedisStore({ client: redisClient, disableTouch: true }),
      saveUninitialized: false,
      secret: process.env.SESSION_SECRET!,
      resave: false,
      cookie: {
        maxAge: 1000 * 60 * 60 * 24 * 365 * 10, // 10 years
        httpOnly: true,
        sameSite: "none",
        secure: true,
      },
    })
  )

  const apolloServer = new ApolloServer({
    schema: await buildSchema({
      resolvers: [PostResolver, UserResolver],
      validate: false,
    }),
    context: ({ req, res }): ApolloContext => ({ emFork, req, res }),
  })

  await apolloServer.start()
  apolloServer.applyMiddleware({ app, cors: corsOptions })

  app.listen(process.env.PORT, () => {
    console.log("Express server started on port:", process.env.PORT)
  })
}

main()

```

Here are my Apollo sandbox settings:

 ![image](https://us1.discourse-cdn.com/flex019/uploads/apollographql/original/2X/c/cfdfee28f773d5beb3e179355c041fbde3255e07.png)

---

<div class="post-metadata">

**Author:** ![Uncasted](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/uncasted/32/4456_2.png) [@Uncasted](https://community.apollographql.com/u/Uncasted)\
**Post date:** [January 30, 2023, 9:58pm UTC](https://community.apollographql.com/t/having-trouble-trying-to-include-cookies-in-apollo-sandbox/5606/2 "2023-01-30T21:58:43Z")

</div>

The console in my dev tools just keeps spamming this, the request for this it contains the cookie, not sure about the meaning of it:

 ![image](https://us1.discourse-cdn.com/flex019/uploads/apollographql/original/2X/e/eeb8b818f7229f5d0c227e558d4a64f0d43aa85d.png)

---

<div class="post-metadata">

**Author:** ![Uncasted](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/uncasted/32/4456_2.png) [@Uncasted](https://community.apollographql.com/u/Uncasted)\
**Post date:** [January 30, 2023, 10:00pm UTC](https://community.apollographql.com/t/having-trouble-trying-to-include-cookies-in-apollo-sandbox/5606/3 "2023-01-30T22:00:51Z")

</div>

When I try to make a request the cookie doesn’t show up in storage.

 ![image](https://us1.discourse-cdn.com/flex019/uploads/apollographql/original/2X/0/0d027a8f0a154684e80971ba713e05a1545635a5.png)

---

<div class="post-metadata">

**Author:** ![watson](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/watson/32/2053_2.png) [@watson](https://community.apollographql.com/u/watson)\
**Post date:** [January 31, 2023, 11:28pm UTC](https://community.apollographql.com/t/having-trouble-trying-to-include-cookies-in-apollo-sandbox/5606/4 "2023-01-31T23:28:53Z")

</div>

I’m not quite sure if you’re using Apollo Server 3 or 4, but with v4 [these docs](https://www.apollographql.com/docs/apollo-server/api/express-middleware) might be helpful in seeing an example. You should be passing the `cors` options to the `app.use`.

We have a new [Discord Server](https://discord.gg/graphos) that we could dive deeper into what is going on here. Feel free to ping me (@watson) if you do join. Hope to see you there!
