Cookie Management

The documentation is constantly evolving and updated alongside the project's progress. Since it is developed in parallel with the code, some sections may temporarily refer to earlier versions of the system-these are gradually adapted to the current state of the application. If you notice any outdated information, please report it or open an Issue / Pull Request.

Documentation

# Cookie Management

# Overview

The CookieManager provides a simple interface for working with cookies.


# Basic Usage

use Dbm\Infrastructure\Cookie\CookieManager;

$cookie = new CookieManager();

$cookie->setCookie('token', 'abc123');

# Options

setCookie(
    string $name,
    string $value,
    int $expiry = 86400,
    bool $secure = true,
    bool $httpOnly = true
)

$value = $cookie->getCookie('token');

$cookie->unsetCookie('token');

# Security

  • secure = true → send only over HTTPS
  • httpOnly = true → not accessible via JS

# Best Practices

  • Always use secure in production
  • Use httpOnly for sensitive data. Deletion currently sends an expired cookie with secure and httpOnly set to true.
  • Avoid storing sensitive info in cookies