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);
89  time_t expires() const;
90 
96  bool expires_defined() const;
100  void max_age(unsigned age);
105  unsigned max_age() const;
111  bool max_age_defined() const;
115  void browser_age();
116 
120  void secure(bool v);
121 
125  bool httponly() const;
126 
130  void httponly(bool v);
131 
135  bool samesite_none() const;
136  bool samesite_lax() const;
137  bool samesite_strict() const;
138 
142  void samesite_none(bool v);
143  void samesite_lax(bool v);
144  void samesite_strict(bool v);
145 
149  bool empty() const;
150 
151  cookie();
152  ~cookie();
153  cookie(cookie const &);
154  cookie(cookie &&);
155  cookie const &operator=(cookie const &);
156  cookie &operator=(cookie &&);
157 
161  cookie(std::string name,std::string value);
165  cookie(std::string name,std::string value,unsigned age);
169  cookie(std::string name,std::string value,unsigned age,std::string path,std::string domain = std::string(),std::string comment=std::string());
172  cookie(std::string name,std::string value,std::string path,std::string domain=std::string(),std::string comment=std::string());
173 
174 private:
175  friend std::ostream &operator<<(std::ostream &,cookie const &);
176 
177  void write(std::ostream &) const;
178  // for future use
179  struct _data;
181 
182  // real members
183  std::string name_;
184  std::string value_;
185  std::string path_;
186  std::string domain_;
187  std::string comment_;
188 
189  unsigned max_age_;
190  time_t expires_;
191 
192  uint32_t secure_ : 1;
193  uint32_t has_age_ : 1;
194  uint32_t has_expiration_: 1;
195  uint32_t httponly_ : 1;
196  uint32_t samesite_none_: 1;
197  uint32_t samesite_lax_: 1;
198  uint32_t samesite_strict_: 1;
199  CPPCMS_UNUSED_MEMBER uint32_t reserved_ : 25;
200 };
201 
202 
203 
204 
205 } } //::cppcms::http
206 
207 
208 #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
This is the namespace where all CppCMS functionality is placed.
Definition: application.h:19
Class that represents single HTTP Cookie Generally used in context of http::request and http::respons...
Definition: http_cookie.h:27