CrowCpp / Crow

A Fast and Easy to use microframework for the web.

Home Page:https://crowcpp.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cookie work cases

ezamosch opened this issue · 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

image

I just decided to work with Cookies directly.