summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--include/kingate/cookies.h2
-rw-r--r--src/cookies.cc10
2 files changed, 12 insertions, 0 deletions
diff --git a/include/kingate/cookies.h b/include/kingate/cookies.h
index a1e813c..cba5aff 100644
--- a/include/kingate/cookies.h
+++ b/include/kingate/cookies.h
@@ -96,6 +96,8 @@ namespace kingate {
96 * @see unset_expires() 96 * @see unset_expires()
97 */ 97 */
98 void set_expires(const string& e); 98 void set_expires(const string& e);
99 void set_expires_time(time_t etime);
100 void set_expires_in(time_t esecs);
99 101
100 /** 102 /**
101 * get cookie parameter. 103 * get cookie parameter.
diff --git a/src/cookies.cc b/src/cookies.cc
index 1ee4f7c..3215271 100644
--- a/src/cookies.cc
+++ b/src/cookies.cc
@@ -96,6 +96,16 @@ namespace kingate {
96 void cookie::set_expires(const string& e) { 96 void cookie::set_expires(const string& e) {
97 (*this)["expires"] = e; 97 (*this)["expires"] = e;
98 } 98 }
99 void cookie::set_expires_time(time_t etime) {
100 struct tm etm;
101 char e[64];
102 if(strftime(e,sizeof(e)-1,"%a, %d %b %Y:%M:%S GMT",gmtime_r(&etime,&etm)))
103 set_expires(e);
104 /* TODO: handle error */
105 }
106 void cookie::set_expires_in(time_t esecs) {
107 set_expires_time(time(0)+esecs);
108 }
99 109
100 const string& cookie::_get_string(const string& s) const { 110 const string& cookie::_get_string(const string& s) const {
101 const_iterator i = find(s); 111 const_iterator i = find(s);