Crow icon indicating copy to clipboard operation
Crow copied to clipboard

Cookie work cases

Open ezamosch opened this issue 10 months ago • 0 comments

I have few question of how to orginize my app to work with cookies:

  1. 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){
    }
};
  1. 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. image 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. image

ezamosch avatar May 02 '24 14:05 ezamosch