summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore 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 {
* @see unset_expires()
*/
void set_expires(const string& e);
+ void set_expires_time(time_t etime);
+ void set_expires_in(time_t esecs);
/**
* 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 {
void cookie::set_expires(const string& e) {
(*this)["expires"] = e;
}
+ void cookie::set_expires_time(time_t etime) {
+ struct tm etm;
+ char e[64];
+ if(strftime(e,sizeof(e)-1,"%a, %d %b %Y:%M:%S GMT",gmtime_r(&etime,&etm)))
+ set_expires(e);
+ /* TODO: handle error */
+ }
+ void cookie::set_expires_in(time_t esecs) {
+ set_expires_time(time(0)+esecs);
+ }
const string& cookie::_get_string(const string& s) const {
const_iterator i = find(s);