Download .zip |
Info | Documentation | View files (14) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2018-04-08 (5 months ago) | Not enough user ratings | Total: 108 | All time: 8,936 This week: 483 |
Version | License | PHP version | Categories | |||
php-cookie 1.1.4 | MIT/X Consortium ... | 5.6 | HTTP, PHP 5 |
Description | Author | |
This class can store and retrieve cookie values. It can: |
PHP library for handling cookies.
This library is supported by PHP versions 5.6 or higher.
The preferred way to install this extension is through Composer.
To install PHP Cookie library, simply:
$ composer require Josantonius/Cookie
The previous command will only install the necessary files, if you prefer to download the entire source code you can use:
$ composer require Josantonius/Cookie --prefer-source
You can also clone the complete repository with Git:
$ git clone https://github.com/Josantonius/PHP-Cookie.git
Or install it manually:
$ wget https://raw.githubusercontent.com/Josantonius/PHP-Cookie/master/src/Cookie.php
Available methods in this library:
Cookie::set($key, $value, $time);
| Attribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $key | Cookie name. | string | Yes | | | $value | The data to save. | string | Yes | | | $time | Expiration time in days. | string | No | 365 |
# Return (boolean)
Cookie::get($key);
| Attribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $key | Cookie name. | string | No | '' |
# Return (mixed|false) ? returns cookie value, cookies array or false
Cookie::pull($key);
| Attribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $key | Cookie name. | string | Yes | |
# Return (string|false) ? item or false when key does not exists
Cookie::destroy($key);
| Attribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $key | Cookie name to destroy. Not set to delete all. | string | No | '' |
# Return (boolean)
Cookie::setPrefix($prefix);
| Attribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $prefix | Cookie prefix. | string | Yes | |
# Return (boolean)
Cookie::getPrefix();
# Return (string) ? cookie prefix
To use this class with Composer:
require __DIR__ . '/vendor/autoload.php';
use Josantonius\Cookie\Cookie;
Or If you installed it manually, use it:
require_once __DIR__ . '/Cookie.php';
use Josantonius\Cookie\Cookie;
Example of use for this library:
Cookie::set('cookie_name', 'value', 365);
Cookie::get('cookie_name');
Cookie::get();
Cookie::pull('cookie_name');
Cookie::destroy('cookie_name');
Cookie::destroy();
Cookie::setPrefix('prefix_');
Cookie::getPrefix();
To run tests you just need composer and to execute the following:
$ git clone https://github.com/Josantonius/PHP-Cookie.git
$ cd PHP-Cookie
$ composer install
Run unit tests with PHPUnit:
$ composer phpunit
Run PSR2 code standard tests with PHPCS:
$ composer phpcs
Run PHP Mess Detector tests to detect inconsistencies in code style:
$ composer phpmd
Run all previous tests:
$ composer tests
If you would like to help, please take a look at the list of issues or the To Do checklist.
Pull requests
composer install
to install the dependencies.
This will also install the dev dependencies.composer fix
to excute code standard fixers.The file structure from this repository was created with PHP-Skeleton.
This project is licensed under MIT license. See the LICENSE file for more info.
2016 - 2018 Josantonius, josantonius.com
If you find it useful, let me know :wink:
Files |
File | Role | Description | ||
---|---|---|---|---|
src (1 file) | ||||
tests (1 file) | ||||
.editorconfig | Data | Auxiliary data | ||
.php_cs.dist | Example | Example script | ||
.travis.yml | Data | Auxiliary data | ||
CHANGELOG.md | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
CONDUCT.md | Data | Auxiliary data | ||
LICENSE | Lic. | License text | ||
phpcs.xml | Data | Auxiliary data | ||
phpmd.xml | Data | Auxiliary data | ||
phpunit.xml | Data | Auxiliary data | ||
README-ES.md | Doc. | Documentation | ||
README.md | Doc. | Documentation |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.