[ Web Proxy ]
URL:
Viewing: https://docs.sonsofphp.com/components/cookie [Back]  [Original]

Cookie | Sons of PHP
[] []
[] []
On this page
For the complete documentation index, see llms.txt. This page is also available as Markdown.
Copy
On this page
  1. Components

Cookie

Installation

Copy
composer require sonsofphp/cookie

Usage

A Cookie is treated as a value object. This means that if two cookie objects have the same name and value, they will be considered equal. They are also considered to be immutable.

Copy
<?php

use SonsOfPHP\Component\Cookie\Cookie;

$cookie = new Cookie('name', 'value');

header('Set-Cookie: ' . $cookie->getHeaderValue());
// OR
// header('Set-Cookie: ' . (string) $cookie);

// Set various attributes
$cookie = $cookie
    ->withPath('/')
    ->withDomain('docs.sonsofphp.com')
;

Last updated 1 year ago


Web Proxy Viewer  |  New URL  |  Original Page