PHP code example of polymorphine / headers

1. Go to this page and download the library: Download polymorphine/headers library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

polymorphine / headers example snippets


   $headers     = new ResponseHeaders();
   $cookieSetup = new CookieSetup($headers);
   

   $cookieSetup = $context->cookieSetup();
   

   $cookieSetup->directives([
       'Domain'   => 'example.com',
       'Path'     => '/admin',
       'Expires'  => new DateTime(...),
       'MaxAge'   => 1234,
       'Secure'   => true,
       'HttpOnly' => true,
       'SameSite' => 'Strict'
   ]);
   

   $cookieSetup->domain('example.com')
               ->path('/admin')
               ->expires(new DateTime(...))
               ->maxAge(1234)
               ->secure()
               ->httpOnly()
               ->sameSite('Strict');
   

   $cookie = $cookieSetup->cookie('MyCookie');
   

   $cookie->send('value');
   

   $cookie->revoke();