如何在mongoose Web服务器上使用c ++设置cookie? 我在这里找到了一些东西https://www.cesanta.com/developer/mongoose#_mg_http_parse_header但是我不确定我是不是在寻找。
答案 0 :(得分:0)
您应该向客户端发送Set-Cookie
HTTP标头。有多种方法可以使用猫鼬,例如使用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");
在http://tools.ietf.org/html/rfc6265中描述了Set-Cookie标头格式。维基百科也有一篇很好的文章,https://en.wikipedia.org/wiki/HTTP_cookie