Download the PHP package activecollab/cookies without Composer

On this page you can find all versions of the php package activecollab/cookies. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cookies

activecollab/cookies

A thin PSR-7 cookie library built on top of dflydev/fig-cookies. It adds automatic name prefixing, optional value encryption, URL-based configuration, and secure defaults so you can work with cookies without worrying about the low-level header plumbing.

Installation

Quick Start

Every method accepts and returns standard PSR-7 message objects (ServerRequestInterface, ResponseInterface), so the library slots into any middleware stack.

How It Works

The library revolves around a single entry point, the Cookies class (implementing CookiesInterface). It is responsible for three operations:

Getting a cookie reads the Cookie header from the incoming request and returns the value for the given name (after optional decryption and prefix resolution).

Setting a cookie applies the value to both the request object (so downstream middleware can see it immediately) and the response object (by adding a Set-Cookie header with all configured attributes like domain, path, expiry, security flags, etc.).

Removing a cookie works like setting operation, but with an empty value and an expiry date in the past, so the browser discards it.

Configuration

All configuration is done through a fluent interface on the Cookies instance. Every setter returns $this, so calls can be chained.

Settings Overview

Setting Getter Setter Default Description
Domain getDomain() domain(string) '' (empty) Cookie domain attribute.
Path getPath() path(string) '/' Cookie path attribute.
Secure getSecure() secure(bool) true Send cookie only over HTTPS.
HttpOnly getHttpOnly() httpOnly(bool) true Hide cookie from JavaScript.
SameSite getSameSite() sameSite(SameSite) Lax Cross-site request policy.
Default TTL getDefaultTtl() defaultTtl(int) 1209600 (14 days) Time-to-live in seconds.
Prefix getPrefix() prefix(string) '' (empty) String prepended to every cookie name.
Encryptor getEncryptor() encryptor(EncryptorInterface) null Encrypt/decrypt cookie values.

Secure, HttpOnly, and the SameSite

The library ships with modern security defaults out of the box:

Override any of them when the use case requires it:

Per-Cookie Settings

The set() method accepts an optional $settings array as its fifth argument. These options override global defaults for that single cookie only:

Key Type Default Description
ttl int Value of getDefaultTtl() (14 days) Time-to-live in seconds. The cookie's Expires attribute is computed as current timestamp plus this value.
http_only bool Value of getHttpOnly() (true) Whether the cookie should be hidden from JavaScript. Set to false for cookies that client-side code needs to read.
same_site SameSite Value of getSameSite() (Lax) Cross-site request policy for this cookie. Accepts SameSite::lax(), SameSite::strict(), or SameSite::none().
encrypt bool true Whether to encrypt the value before writing. Only relevant when an encryptor is configured. Set to false to store the value in plain text.

All other cookie attributes (domain, path, and secure) are always taken from the global Cookies configuration and cannot be overridden per cookie.

Example — a short-lived, JS-accessible, unencrypted preference cookie:

Example — a CSRF token cookie with a stricter same-site policy than the global default:

Configure From URL

The most convenient way to configure domain, path, secure, and prefix all at once is from your application's URL:

An http:// URL will set secure to false. The prefix is only auto-generated when one has not already been set, so calling prefix() before configureFromUrl() preserves your choice.

Cookie Name Prefixing

Prefixing avoids collisions when multiple applications share the same domain:

Encryption

When an encryptor is provided, cookie values are automatically encrypted on set() and decrypted on get(). The encryptor must implement ActiveCollab\Encryptor\EncryptorInterface from the activecollab/utils package.

To skip encryption for a specific cookie, pass 'encrypt' => false in settings:

TTL and Expiry

The default time-to-live is 14 days. Change it globally or per cookie:


All versions of cookies with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
ext-openssl Version *
activecollab/utils Version ^3.0
dflydev/fig-cookies Version ^3.0
psr/http-server-middleware Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package activecollab/cookies contains the following files

Loading the files please wait ...