Decode appSession cookie

I am attempting to create a provider using the Vercel Flags SDK. They provide a hook to identify the user and it is supplied the Headers and Cookies from the request but not the actual Request/Response objects. Normally I would use getSession(req, res) but this is unavailable to me. I can see the appSession cookie in the cookies passed in but I am not sure the best way to decode it on the server side so I can extract the UserId.

Any thoughts or help would be appreciated!

Hi @bkstok

Welcome to the Auth0 Community!

Depending on the technology used, with Next.js you could be able to decode the JWT header, but not the payload, on the https://jwt.io/ website. Although this following Community post does not tackle Vercel directly, it still goes over some issues with decoding the appSession cookie and I recommend that you look over it.

Allow me to link some other pages that could prove useful in this case:

Let us know if these resources helped resolve the issue!
Gerald

Hi Gerald,

Thanks for the response. I had previously reviewed those documents and wasn’t able to come to a solution. I attempted to link to those documents and provide a better in depth explanation with references to API docs but was not allowed to post links.

I have an established NextJS App using the Page Router. The @auth0/nextjs-auth0 provides a getSession call which requires the request and response to be passed into it. That works normally in the getServerSideProps call.

The @vercel/flags library provides a way to evaluate feature flags on the server side. It accepts the request and then provides a hook for determining the identity. In that hook only the Cookies and Headers are provided. In the Cookies I am able to see the appSession cookie.

How can I access the information in the appSession cookie when I don’t have the full request and response objects?