谁能提供给我示例代码,使用Wininet API在C ++中创建会话Cookie [英] Can anyone provide me sample code creating a session cookie in c++ using wininet API

查看:87
本文介绍了谁能提供给我示例代码,使用Wininet API在C ++中创建会话Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用c ++创建会话cookie,而无需使用任何第三方CGI.

I Want to create a session cookie in c++ with out using any third party CGI.

推荐答案

好,所以您知道如何创建http请求/响应标头对吧?
只需为cookie添加一个字段并进行设置即可.

示例请求标头:
Okay, so you know how to create http request/response headers, right?
Just add a field for the cookies and set them.

Example Request header:
GET /script/Answers/List.aspx?tab=active HTTP/1.1
Host: www.codeproject.com
Connection: keep-alive
Cache-Control: max-age=0
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Referer: http://www.codeproject.com/script/Membership/MyNotifications.aspx
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Cookie: srvid=1328, 1335; ui-tabs-1=0; cntid=16;




示例响应标头:




Example Response header:

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Encoding: gzip
Vary: Accept-Encoding
Set-Cookie: SessionGUID=<identifying value="" removed="">; path=/
Set-Cookie: mguid=<identifying value="" removed="">; domain=.codeproject.com; expires=Sat, 12-Sep-2037 04:00:00 GMT; path=/
Set-Cookie: SessionGUID=<identifying value="" removed="">; path=/
Set-Cookie: mguid=<identifying value="" removed="">; domain=.codeproject.com; expires=Sat, 12-Sep-2037 04:00:00 GMT; path=/
Date: Wed, 12 Sep 2012 18:51:25 GMT
Content-Length: 13947
</identifying></identifying></identifying></identifying>


这篇关于谁能提供给我示例代码,使用Wininet API在C ++中创建会话Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆