APPNETOS is under active development This website and its documentation are being prepared for public launch. Content and features may change.
Select Theme
Loading

Cookie

Manages logical cookie keys with application/context-aware physical names, default expiration and typed access.

Logical and physical names

Application code uses logical cookie keys. APPNETOS builds physical cookie names using application and base-context information, with optional session scope. getAll() returns physical names, unlike logical-key lookups.

Use Core\Cookie instead of direct $_COOKIE access or setcookie() calls. The controller applies the configured cookie behavior.

Example

$cookie = Registry::get(Cookie::class);
$language = $cookie->getString('LANGUAGE');

Public API Reference

Core\Cookie

Class & Registry

Class: Core\Cookie

Extends: Core\Cookie\Base

use Core\Cookie;
use Core\Registry;

$cookie = Registry::get(Cookie::class);
Method Description
init():void Initializes the cookie controller by resolving the active runtime state used for session-scoped cookie naming.
set(string $key, string $value, int|null $expires = null, string $path = '/', bool|null $secure = null, bool $httpOnly = true, string $sameSite = 'Lax'):void Sets a cookie using an automatically generated APPNETOS cookie name. Supports configurable lifetime, path, HTTPS security, HttpOnly and SameSite options, and updates the current request cookie data.
remove(string $key, string $path = '/', bool|null $secure = null, bool $httpOnly = true, string $sameSite = 'Lax'):void Expires the specified cookie using its generated APPNETOS name and removes it from the current request cookie data.
clear():void Expires all cookies currently available in the request and removes them from the PHP $_COOKIE superglobal.
get(string $key):mixed Returns a cookie value using its logical APPNETOS key, or null if the cookie is missing or its value is null.
getString(string $key, string $default = ''):string Returns a cookie value converted to a string. Missing cookies or non-scalar values return the specified default.
getInt(string $key, int $default = 0):int Returns a cookie value validated as an integer, or the specified default if validation fails or the cookie is missing.
getFloat(string $key, float $default = 0.0):float Returns a cookie value validated as a float, or the specified default if validation fails or the cookie is missing.
getBool(string $key, bool $default = false):bool Returns a cookie value validated as a boolean, or the specified default if validation fails or the cookie is missing.
getArray(string $key, array $default = []):array Returns an existing cookie array unchanged or wraps a non-null value in an array. Missing or null values return the specified default.
has(string $key):bool Checks whether a cookie exists using its generated APPNETOS name, including cookies explicitly containing null.
getAll():array Returns all physical cookie names and values currently available in the PHP $_COOKIE superglobal.
getDefaultExpires():int Returns the configured default cookie lifetime in seconds.
setDefaultExpires(int $defaultExpires):void Sets the default cookie lifetime in seconds, ensuring that the value cannot be negative.

Next Steps

Previous

Post

Explore Post

Next

Redirect

Explore Redirect