Crow
Crow copied to clipboard
Cookie work cases
I have few question of how to orginize my app to work with cookies:
- I want to create custom middleware, which will check request cookie for session. I already know that Crow provides Cookie middleware from the box, but I guess I can't use it in other middleware. So maybe you can advice what is best practice to get Cookie's value inside custom middleware?
struct SessionCheck : crow::ILocalMiddleware
{
struct context{
std::string message;
};
void before_handle(crow::request& req, crow::response& /*res*/, context& /*ctx*/){
//here I want to get Cookie session and check session in Redis storage
std::string cookieString = req.get_header_value("Cookie");
}
void after_handle(crow::request& /*req*/, crow::response& res, context& ctx){
}
};
- I have some wierd issue with setting up Cookie. I am currently looking at this example, where I can set up additional parameters for Cookie, but when I copy paste it in my app I get error.
By the way I can compile my program without specifying those additional parameters.
If I understand right, then I am using version 1.05 of Crow which is installed by Vcpkg.