0

My application has some encrypted cookies with dynamic names. I have implemented the middleware for encryption and it is working fine for those cookies with static names such as xxx, yyy and zzz.

    $cookiesEncrypted = new EncryptedCookieMiddleware(
        // Names of cookies to protect
        [
            'xxx','yyy','zzz'
        ],
        Configure::read('Security.cookieKey')
    );

    $middlewareQueue->add($cookiesEncrypted)       

However, I'm not sure how exactly could I encrypt the cookies with the dynamic names. For example, if my cookie name is '3HA8_settings', where the prefix 3HA8 is some product id, how do I declare or access the cookie name inside my Application.php for encryption.

Can anybody throw some light on how this could be achieved?

As suggested previously, I had read through the middleware links provided below but it doesn't really help me with the above issue. I must have miss out something somewhere.

EssEss
  • 73
  • 10
  • 1
    What kind of data, and how much data do you need to store there? Couldn't you store inidivdual configuration in a single cookie? – ndm Jun 12 '18 at 18:59
  • Thanks for your suggestion, I managed to store the individual configuration data as arrays in a single cookie and it works. – EssEss Jun 14 '18 at 03:22

0 Answers0