react cookie
#include <iostream>
#include "reactcookie/reactcookie.h"
int main() {
// Set a cookie with a name and value
reactcookie::setCookie("username", "JohnDoe");
// Get the value of a cookie by its name
std::string username = reactcookie::getCookie("username");
// Check if a cookie exists
bool cookieExists = reactcookie::cookieExists("username");
// Delete a cookie by its name
reactcookie::deleteCookie("username");
return 0;
}
Explanation:
#include <iostream>
: Includes the input/output stream library for handling input and output operations."reactcookie/reactcookie.h"
: Includes the header file for using the React Cookie library in C++.reactcookie::setCookie("username", "JohnDoe");
: Sets a cookie named "username" with the value "JohnDoe".std::string username = reactcookie::getCookie("username");
: Retrieves the value of the cookie named "username" and stores it in the variableusername
.bool cookieExists = reactcookie::cookieExists("username");
: Checks if a cookie named "username" exists and stores the result in the boolean variablecookieExists
.reactcookie::deleteCookie("username");
: Deletes the cookie named "username".return 0;
: Ends themain()
function and returns 0, indicating successful execution of the program.