PHP code example of dankkomcg / cookie-manager

1. Go to this page and download the library: Download dankkomcg/cookie-manager 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/ */

    

dankkomcg / cookie-manager example snippets


use Dankkomcg\Cookie\CookieManager;

// Create a cookie that expires in 1 hour
CookieManager::create('user_session', 'abc123', time() + 3600, '/', 'example.com', true, true);

use Dankkomcg\Cookie\CookieManager;

// Delete a cookie
CookieManager::delete('user_session', '/', 'example.com');

use Dankkomcg\Cookie\CookieManager;

// Get all cookies
$cookies = CookieManager::getCookies();
print_r($cookies);

// Set server timezone
date_default_timezone_set('Europe/Madrid');