Re: cowboy: session state and connection timeout
Roger Lipscombe <[email protected]>
| Newsgroups | gmane.comp.lang.erlang.general |
|---|---|
| Message-ID | <CAJgnQd_Nf=How13qYEW6BMuqpOJ9_fB=1rfBwgtz3iK6CXc21Q@mail.gmail.com> |
On Tue, 2 Mar 2021 at 04:14, jdmeta <[email protected]> wrote: > it's still not completely clear to me how to maintain session state even for http in cowboy. > this is a well-known function in most web serving frameworks. > do i have to roll-my-own? Yes. Cowboy isn't a web *framework*; it's a web *server*. There are several web frameworks built on top of it. The most popular, if you're prepared to use Elixir, is Phoenix: https://www.phoenixframework.org/. For Erlang. I think that the one that's most actively maintained is https://nitrogenproject.com/. There are others. If you don't want to use one of those, and if you want session support, you'll have to find a library that implements it, or implement your own. There's some documentation about using cookies with cowboy here: https://ninenines.eu/docs/en/cowboy/2.5/guide/cookies/, but -- if you want server-side sessions -- you'll need to combine that with a session store, probably in ETS. Searching online for "cowboy session" returns two Erlang libraries, both kinda old, but you can use them as inspiration.