#pragma once #include #include namespace VWeb { enum class CookieSameSite { Invalid = 0, Strict, Lax, None }; struct Cookie { std::string Name{}; std::string Value{}; std::string Expires{}; int MaxAge{}; std::string Domain{}; std::string Path{"/"}; bool Secure{}; bool HttpOnly{}; CookieSameSite SameSite{CookieSameSite::Strict}; bool IsOld = false; }; struct Cookies { public: void Remove(const std::string &name); bool Has(const std::string &name) const; Cookie &Get(const std::string &name) { return Data[name]; }; std::string TransformToHeader(); void CreateCookieFromString(const std::string &data); void CreateOld(const std::string &name, const std::string &value); std::unordered_map Data; Cookie &operator[](const std::string &name) { return Data[name]; } protected: static void CookieToString(std::stringstream &stream, Cookie &cookie); }; } // namespace VWeb