CppCMS
http_cookie.h
1 //
3 // Copyright (C) 2008-2012 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
4 //
5 // See accompanying file COPYING.TXT file for licensing details.
6 //
8 #ifndef CPPCMS_HTTP_COOKIE_H
9 #define CPPCMS_HTTP_COOKIE_H
10 
11 #include <cppcms/defs.h>
12 #include <booster/copy_ptr.h>
13 
14 #include <string>
15 #include <iostream>
16 #include <cppcms/cstdint.h>
17 namespace cppcms { namespace http {
18 
19 class cookie;
20 std::ostream CPPCMS_API &operator<<(std::ostream &,cookie const &);
21 
26 
27 class CPPCMS_API cookie {
28 public:
32  std::string name() const;
33 
37  std::string value() const;
41  std::string path() const;
42 
46  std::string domain() const;
50  std::string comment() const;
51 
55  bool secure() const;
56 
60  void name(std::string n);
61 
65  void value(std::string v);
66 
70  void path(std::string p);
71 
75  void domain(std::string);
79  void comment(std::string);
80 
84  void expires(time_t when);
88  void max_age(unsigned a);
92  void browser_age();
93 
97  void secure(bool v);
98 
102  bool empty() const;
103 
104  cookie();
105  ~cookie();
106  cookie(cookie const &);
107  cookie const &operator=(cookie const &);
108 
112  cookie(std::string name,std::string value);
116  cookie(std::string name,std::string value,unsigned age);
120  cookie(std::string name,std::string value,unsigned age,std::string path,std::string domain = std::string(),std::string comment=std::string());
123  cookie(std::string name,std::string value,std::string path,std::string domain=std::string(),std::string comment=std::string());
124 
125 private:
126  friend std::ostream &operator<<(std::ostream &,cookie const &);
127 
128  void write(std::ostream &) const;
129  // for future use
130  struct _data;
132 
133  // real members
134  std::string name_;
135  std::string value_;
136  std::string path_;
137  std::string domain_;
138  std::string comment_;
139 
140  unsigned max_age_;
141 
142  uint32_t secure_ : 1;
143  uint32_t has_age_ : 1;
144  uint32_t has_expiration_: 1;
145  uint32_t reserved_ : 29;
146 };
147 
148 
149 
150 
151 } } //::cppcms::http
152 
153 
154 #endif
details::set_domain domain(std::string const &id)
Definition: message.h:789
std::basic_ostream< CharType > & operator<<(std::basic_ostream< CharType > &out, date_time const &t)
Definition: date_time.h:874
Class that represents single HTTP Cookie Generally used in context of http::request and http::respons...
Definition: http_cookie.h:27