Luminova Framework

PHP Luminova: Client Cookies Security Configurations

Last updated: 2026-11-28 20:57:12

Set default cookie lifetimes, paths, domains, and security attributes.

The Cookie Configuration class allows you to manage and customize cookies in your web application. You can control client-side cookie behavior, including expiration, path, domain, SameSite policy, and security flags, giving you full control over how cookies are stored and used.


Class Definition

  • Full namespace: App\Config\Cookie
  • File path: /app/Config/Cookie.php
  • This configuration derives from Luminova\Base\AbstractConfig.
  • This class is final.

Properties

expiration

The cookie's expiration time in seconds.

public int $expiration = 30 * 24 * 60 * 60;

This determines how long the cookie remains valid. The default is 30 days.


cookiePath

The path where the cookie is accessible.

public string $cookiePath = '/';

This restricts the availability of this cookie to a specific URI path (e.g., '/my-project/').


cookieDomain

The domain for which the cookie is valid.

public string $cookieDomain = '.localhost';

This determines which domains can access the cookie. When the application runs in production (PRODUCTION is enabled), the value is automatically replaced with '.' . APP_HOSTNAME when the configuration is created.


sameSite

The SameSite policy for cookies.

Defines how cookies are sent with cross-site requests.

Options: None, Lax, Strict

public string $sameSite = 'Lax';

If set to None, the cookie must also be marked as secure, otherwise a CookieException is thrown when the cookie is created.


secure

Enforce secure cookies by requiring an HTTPS connection.

public bool $secure = false;

If enabled, cookies will not be sent over an insecure HTTP connection.


httpOnly

Restrict cookie access to HTTP(S) requests only.

If enabled, JavaScript cannot access the cookie via document.cookie.

public bool $httpOnly = true;

cookieRaw

Enable setting raw (non-URL-encoded) cookies.

If enabled, cookie names and values must comply with RFC 2616, i.e., its name and value are not URL encoded using rawurlencode() leaving the cookie as it was.

public bool $cookieRaw = false;

When enabled, a cookie name containing reserved characters causes a CookieException.


Hooks

onCreate

In production, set the cookie domain to a dot followed by APP_HOSTNAME.

protected function onCreate(): void

See Also

  • Luminova\Cookies\Cookie
  • Luminova\Cookies\FileJar

See Reference: