0

I am writing and application in Slim Framework v3.1. I am a lot confused on how to correctly set and get the cookies using Slim's methods.

I need your help in understanding what is the right way to read and write cookies with encryption enabled.

I also need to know how to enable encryption and decryption for the same.

Currently my $app is initialised this way -

$settings = require __DIR__ . '/../src/settings.php';
$app = new \Slim\App($settings);

My settings.php looks like below -

return [
    'settings' => [
        'displayErrorDetails' => true, // set to false in production
        'addContentLengthHeader' => false, // Allow the web server to send the content-length header

        // Renderer settings
        'renderer' => [
            'template_path' => __DIR__ . '/../templates/',
        ],
       // Cookies Encryption
        'cookies.encrypt' => true,
        'cookies.secret_key' => '53cr3t',
        'cookies.cipher' => OPENSSL_CIPHER_AES_256_CBC,
        'cookies.cipher_mode' => MCRYPT_MODE_CBC,
    ],
];
ArunKolhapur
  • 5,805
  • 4
  • 18
  • 31
  • Are you using any third party packages for this? If so, please mention the package as well. – Nima Sep 18 '17 at 19:21
  • @Nima I am not using any third party package for this. I have followed the instructions from slim framework v2 documentation. But, seems like, with slim v3 the standards changed due to PSR-7. – ArunKolhapur Sep 18 '17 at 19:35
  • Yes Slim framework 2 has changed a lot. It does not provide any session or cookie handling out of the box, that's why I asked my first question. You should consider reading new documentation. – Nima Sep 18 '17 at 19:37
  • I have started with FigCookies as well. But, seems like there is no documentation for encryption and decryption part of FigCookies. – ArunKolhapur Sep 18 '17 at 19:39

0 Answers0