如何在 mongoose 服务器上设置 cookie?

How set cookies on mongoose server?

如何在猫鼬 Web 服务器上使用 C++ 设置 cookie? 我在这里找到了一些东西 https://www.cesanta.com/developer/mongoose#_mg_http_parse_header 但我不确定我在找什么。

您应该向客户端发送 Set-Cookie HTTP header。使用猫鼬有多种方法,例如使用 mg_send_head()https://www.cesanta.com/developer/mongoose#_mg_send_head :

mg_send_head(conn, 200, content_len, "Set-Cookie: token=1234; Expires=Wed, 09 Jun 2021 10:18:14 GMT");

Set-Cookie header 格式在 https://www.rfc-editor.org/rfc/rfc6265. Wikipedia also has a good article on it, https://en.wikipedia.org/wiki/HTTP_cookie

中描述