Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/commandstring/cookies
A simpler way to manipulate cookies in PHP
https://github.com/commandstring/cookies
Last synced: 1 day ago
JSON representation
A simpler way to manipulate cookies in PHP
- Host: GitHub
- URL: https://github.com/commandstring/cookies
- Owner: CommandString
- License: mit
- Created: 2022-08-21T04:26:23.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-02T21:03:10.000Z (11 months ago)
- Last Synced: 2024-04-03T01:42:26.659Z (7 months ago)
- Language: PHP
- Homepage:
- Size: 43 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [CommandString/Cookies](https://packagist.org/packages/commandstring/cookies) - A simpler way to manipulate cookies in PHP #
### Install with Composer using `composer require commandstring/cookies` ###
## Requirements ##
- PHP >=8.0
- Basic understanding of PHP OOP
- Composer 2## Basic Usage ##
```php
require __DIR__."/vendor/autoload.php";
use CommandString\Cookies\Cookie;$cookies = new Cookie();
# v hours
# v valid v seconds valid
$cookies->set("name", "value", 168, 10, 30); // by default cookies expire in a week
# ^ minutes valid// After page refresh //
echo $cookies->get("name"); // output: value// Delete cookie //
$cookie->delete("name"); // remove the cookie// Delete all cookies
$cookie->deleteAll();// Check if a cookie exists
$cookie->exists("name"); // returns bool
```## Using CommandString/Encrypt with CommandString/Cookies ##
### *[I recommend checking out the README for CommandString/Encrypt](https://github.com/CommandString/encrypt#basic-usage)* ###
```php
use CommandString\CookieEncryption\CookieEncryption;
use CommandString\Cookies\Cookie;// use the cookieEncryption class that wraps around cmdstr/encrypt/encryption class
$cookies = new Cookie(new CookieEncryption("MZCdg02STLzrsj05KE3SIL62SSlh2Ij", "AES-256-CTR"));
// ... now cmdstr/encrypt will handle encrypting cookies
```