Pop PHP Framework
v4.7.0
  • Overview
  • Installation
  • Getting Started
  • User Guide
  • Tutorial Application
  • Reference
    • pop-acl
    • pop-application
    • pop-audit
    • pop-auth
    • pop-cache
    • pop-code
    • pop-config
    • pop-console
    • pop-controller
    • pop-cookie
      • Installation
      • Basic Use
    • pop-css
    • pop-csv
    • pop-db
    • pop-debug
    • pop-dir
    • pop-dom
    • pop-event
    • pop-filter
    • pop-form
    • pop-ftp
    • pop-http
    • pop-i18n
    • pop-image
    • pop-kettle
    • pop-loader
    • pop-log
    • pop-mail
    • pop-mime
    • pop-module
    • pop-nav
    • pop-paginator
    • pop-pdf
    • pop-queue
    • pop-router
    • pop-service
    • pop-session
    • pop-storage
    • pop-utils
    • pop-validator
    • pop-view
    • popcorn
  • Changelog
Pop PHP Framework
  • Docs »
  • Reference »
  • pop-cookie
  • Edit on GitHub

pop-cookie¶

The popphp/pop-cookie component provides the basic functionality to manage cookies.

Installation¶

Install it directly into your project:

composer require popphp/pop-cookie

Or, include it in your composer.json file:

{
    "require": {
        "popphp/pop-cookie": "^3.3.1"
    }
}

Basic Use¶

The cookie component allows you to interact with and manage cookies within the user’s session. When you create a new instance of a cookie object, you can pass it some optional parameters for more control:

$cookie = Pop\Cookie\Cookie::getInstance([
    'expires'  => 300,
    'path'     => '/system',
    'domain'   => 'www.domain.com',
    'secure'   => true,
    'httponly' => true,
    'samesite' => 'Strict'
]);

These are all options that give you further control over when a cookie value expires and where and how it is available to the user. From there, you can store and retrieve cookie values like this:

$cookie->foo   = 'bar';
$cookie['baz'] = 123;

echo $cookie->foo;   // echos 'bar'
echo $cookie['baz']; // echos 123

And then you can delete a cookie value like this:

$cookie->delete('foo');
unset($cookie['baz']);
Next Previous

© Copyright 2023 NOLA Interactive Revision 18166aae.

Built with Sphinx using a theme provided by Read the Docs.
Read the Docs v: v4.7.0
Versions
latest
stable
v4.7.0
v4.6.0
v4.5.0
v4.1.0
v4.0.0
v3.8.0
v3.5.0
v3.0.0
v2.1.1
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.