kegi / netscape-cookie-file-handler
Netscape Cookie File Handler
Installs: 4 108
Dependents: 0
Suggesters: 0
Security: 0
Stars: 23
Watchers: 2
Forks: 3
Open Issues: 0
Requires
- php: >=7.0
Requires (Dev)
- codeclimate/php-test-reporter: dev-master
- phpunit/phpunit: ^5.2
This package is not auto-updated.
Last update: 2024-11-09 19:45:39 UTC
README
This library allows you to manipulate Netscape Cookie File (eg. Cookies generated by CURL).
Requirements
This is library is only available for PHP7+ There is no other dependencies
Installation
This library is available on packagist (Composer)
composer require kegi/netscape-cookie-file-handler
What are Cookies Files ?
The Netscape cookie files are widely used. Curl, by example, allows you to select a file (called the cookie jar) to save and read the cookies using this format. This library will help you to manipulate and read those cookies.
Example
Simple example of reading + writing cookies
/*Open and parse the cookie file*/ $configuration = (new Configuration())->setCookieDir('cookies/'); $cookieJar = (new CookieFileHandler($configuration))->parseFile('my_cookie_file'); /*Add (and save) a cookie*/ $cookieJar->add( (new Cookie()) ->setHttpOnly(true) ->setPath('/foo') ->setSecure(true) ->setExpire(new DateTime('2020-02-20 20:20:02')) ->setName('foo') ->setValue('bar') )->persist();
Documentation
Learn how to use the library here : documentation.
Contribution
Feel free to contact me or send pull requests !