Download the PHP package josantonius/cookie without Composer
On this page you can find all versions of the php package josantonius/cookie. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download josantonius/cookie
More information about josantonius/cookie
Files in josantonius/cookie
Informations about the package cookie
PHP Cookie library
Translations: Español
PHP library for handling cookies.
- Requirements
- Installation
- Available Classes
- Cookie Class
- Cookie Facade
- Exceptions Used
- Usage
- About Cookie Expires
- Tests
- TODO
- Changelog
- Contribution
- Sponsor
- License
Requirements
-
Operating System: Linux.
- PHP versions: 8.1 | 8.2 | 8.3.
Installation
The preferred way to install this extension is through Composer.
To install PHP Cookie library, simply:
The previous command will only install the necessary files, if you prefer to download the entire source code you can use:
You can also clone the complete repository with Git:
Available Classes
Cookie Class
Josantonius\Cookie\Cookie
Sets cookie options:
Sets a cookie by name:
Sets several cookies at once:
Gets a cookie by name:
Gets all cookies:
Check if a cookie exists:
Deletes a cookie by name and returns its value:
Deletes an cookie by name:
Cookie Facade
Josantonius\Cookie\Facades\Cookie
Sets cookie options:
Sets a cookie by name:
Sets several cookies at once:
Gets a cookie by name:
Gets all cookies:
Check if a cookie exists:
Deletes a cookie by name and returns its value:
Deletes an cookie by name:
Exceptions Used
Usage
Example of use for this library:
Create Cookie instance with default options
Create Cookie instance with custom options
Sets a cookie by name
Sets a cookie by name modifying the expiration time
Sets several cookies at once
Sets several cookies at once modifying the expiration time
Gets a cookie by name
Gets a cookie by name with default value if cookie does not exist
Gets all cookies
Check if a cookie exists
Deletes a cookie by name and returns its value
Deletes a cookie and returns its value or default value if does not exist
Deletes an cookie by name
About cookie expires
-
The expires parameter used in several methods of this library accepts the following types:
int|string|DateTime
.Integers
will be handled as unix time except zero.Strings
will be handled as date/time formats. See supported Date and Time Formats for more information.
It would be similar to:
DateTime
objects will be used to obtain the unix time.
-
If the expires parameter is used in the
set
orreplace
methods, it will be taken instead of the expires value set in the cookie options. - If the expires parameter passed in the options is a date/time string,
it is formatted when using the
set
orreplace
method and not when setting the options.
Tests
To run composer and to execute the following:
Run unit tests with PHPUnit:
Run code standard tests with PHPCS:
Run PHP Mess Detector tests to detect inconsistencies in code style:
Run all previous tests:
TODO
- [ ] Add new feature
- [ ] Improve tests
- [ ] Improve documentation
- [ ] Improve English translation in the README file
- [ ] Refactor code for disabled code style rules (see phpmd.xml and phpcs.xml)
Changelog
Detailed changes for each release are documented in the release notes.
Contribution
Please make sure to read the Contributing Guide, before making a pull request, start a discussion or report a issue.
Thanks to all contributors! :heart:
Sponsor
If this project helps you to reduce your development time, you can sponsor me to support my open source work :blush:
License
This repository is licensed under the MIT License.
Copyright © 2016-present, Josantonius