Mason Wheeler
Mason Wheeler

Reputation: 84640

How do I configure a session cookie in Azure Functions?

Every Web server framework has the concept of sessions, where the server uses a cookie to identify logged-in users. I'm looking at migrating an existing Web API server to work on Azure Functions, but I can't find anything on how it handles sessions, either in the documentation or on StackOverflow or other third-party resources.

Any searches I do tend to return a bunch of stuff that's not at all relevant, mixed with a bunch of authentication stuff about getting the user to sign in with a 3rd party provider such as Microsoft, Facebook, or Google. But I already have a working login system, and also the client is a SPA, so navigating off of it to a third-party login page is a bad idea.

So I'm finding myself quite frustrated at not finding any good answer to what ought to be an extremely simple question: how does session cookie management work in Azure Functions? (Specifically, C# precompiled HTTP trigger v2 functions. More specifically, I need to be able to configure a custom name for the session cookie, set the value of the cookie, retrieve the value of the cookie, and drop the cookie if the user logs out.)

Upvotes: 1

Views: 1873

Answers (1)

Mikhail Shilkov
Mikhail Shilkov

Reputation: 35144

The primary use cases for Azure Functions are stateless, and sessions are a bit against this principle. You can probably emulate it yourself by using Request.Cookies and Response.Cookies but ASP.NET features aren't directly applicable in Functions.

Upvotes: 4

Related Questions