| 59 | } |
| 60 | |
| 61 | std::string BrowserCookie::ToString() const { |
| 62 | std::string cookie_string(this->name_ + |
| 63 | "=" + |
| 64 | this->value_ + |
| 65 | "; "); |
| 66 | |
| 67 | if (this->is_secure_) { |
| 68 | cookie_string += "secure; "; |
| 69 | } |
| 70 | |
| 71 | if (this->expiration_time_ > 0) { |
| 72 | time_t expiration_time = static_cast<time_t>(this->expiration_time_); |
| 73 | time_t current_time; |
| 74 | time(¤t_time); |
| 75 | long long expiration_seconds = expiration_time - current_time; |
| 76 | cookie_string += "max-age=" + std::to_string(expiration_seconds) + ";"; |
| 77 | } |
| 78 | |
| 79 | if (this->domain_.size() > 0) { |
| 80 | cookie_string += "domain=" + this->domain_ + "; "; |
| 81 | } |
| 82 | if (this->path_.size() > 0) { |
| 83 | cookie_string += "path=" + this->path_ + "; "; |
| 84 | } |
| 85 | return cookie_string; |
| 86 | } |
| 87 | |
| 88 | Json::Value BrowserCookie::ToJson() { |
| 89 | Json::Value cookie; |