5
5
#include " curl_form.h"
6
6
#include " curl_cookie.h"
7
7
#include " curl_ios.h"
8
+ #include " cookie_datetime.h"
8
9
9
10
using std::ostringstream;
10
11
@@ -15,7 +16,9 @@ using curl::curl_easy_exception;
15
16
using curl::curl_cookie;
16
17
using curl::curlcpp_cookies;
17
18
using curl::curl_ios;
18
-
19
+ using curl::cookie_date;
20
+ using curl::cookie_time;
21
+ using curl::cookie_datetime;
19
22
20
23
/* *
21
24
* This example shows to how to set and get cookies in a
@@ -32,13 +35,17 @@ int main() {
32
35
curl_easy easy (ios);
33
36
easy.add <CURLOPT_URL>(" http://example.com" );
34
37
35
- // Let's create a cooie
38
+ // Let's create a cookie which expires at Mon, 27-03-2016 20:30:30 GMT
36
39
cookie ck;
40
+ cookie_date date (curl::weekdays::MONDAY,27 ,curl::months::MARCH,2016 );
41
+ cookie_time time (20 ,30 ,30 );
42
+ cookie_datetime datetime (time,date);
43
+
37
44
ck.set_name (" nomecookie" );
38
45
ck.set_value (" valorecookie" );
39
46
ck.set_path (" /" );
40
47
ck.set_domain (" .example.com" );
41
- std::cout<< ck.get_formatted ()<<std::endl ;
48
+ ck.set_datetime (datetime) ;
42
49
43
50
// Create a cookie object and add the previously created cookie.
44
51
curl_cookie c_obj (easy);
@@ -51,11 +58,10 @@ int main() {
51
58
// Retrieve all the cookies for the example.com
52
59
cookies = c_obj.get ();
53
60
// Delete all the memory helded cookies.
54
- easy. add <CURLOPT_COOKIEFILE>( " ALL " );
61
+ c_obj. erase ( );
55
62
} catch (curl_easy_exception error) {
56
63
error.print_traceback ();
57
64
}
58
- std::cout<<cookies.size ()<<std::endl;
59
65
// Print them all!
60
66
for (auto cook : cookies) {
61
67
std::cout<<cook<<std::endl;
0 commit comments