Browse Source

Exteded API - added getters for max_age/expires

master
Artyom Beilis 8 years ago
parent
commit
fd4af7b547
2 changed files with 44 additions and 1 deletions
  1. +20
    -1
      cppcms/http_cookie.h
  2. +24
    -0
      src/http_cookie.cpp

+ 20
- 1
cppcms/http_cookie.h View File

@@ -83,9 +83,28 @@ public:
///
void expires(time_t when);
///
/// Returns expires timestamp for the cookie, if not set returns 0
///
time_t expires() const;

///
/// returns true if expires(time_t when) was called and expiration was set,
/// if browser_age() is called it is reset to false
///
bool expires_defined() const;
///
/// Set max cookie's age
///
void max_age(unsigned a);
void max_age(unsigned age);
///
/// Get max cookie's age, returns 0 if not set
///
unsigned max_age() const;
///
/// returns true if max(unsigned age) was called and max_age was set,
/// if browser_age() is called it is reset to false
///
bool max_age_defined() const;
///
/// Set age according to browser's session (i.e. no Max-Age)
///


+ 24
- 0
src/http_cookie.cpp View File

@@ -41,11 +41,35 @@ void cookie::expires(time_t when)
has_expiration_=1;
d->expires = when;
}

time_t cookie::expires() const
{
if(has_expiration_)
return d->expires;
return 0;
}
bool cookie::expires_defined() const
{
return has_expiration_ == 1;
}


void cookie::max_age(unsigned age)
{
has_age_=1;
max_age_=age;
}
bool cookie::max_age_defined() const
{
return has_age_ == 1;
}
unsigned cookie::max_age() const
{
if(has_age_)
return max_age_;
return 0;
}

void cookie::browser_age()
{
has_age_=0;


Loading…
Cancel
Save