omerfdmrl / cookie
Cookie Class
v2.1.11
2021-11-05 06:35 UTC
README
Simple and Light Cookie Class for Php
Features
- Create, Delete, Set Cookie
- Set Prefix, Domain, Secure, OnlyHttp, Path
Install
run the following command directly.
$ composer require omerfdmrl/cookie
Usage
include 'vendor/autoload.php'; use Omerfdmrl\Cookie\Cookie; $cookie = new Cookie; // You can change cookie name's prefix $cookie->set_prefix('prefix_'); // They will be work on just $_SERVER['HTTPS']; // Default is False $cookie->set_secure(False); // They will be work just HTTP protocol. Sometimes they can block xss attacks. // Default is False $cookie->set_onlyHttp(False); // For use in path. If you set as '/path/path2'; Cookie will start only '/path/path2' // Default is '' $cookie->set_path('/path'); // If you set it like this, cookie will saved for subdomains to // Default is '' $cookie->set_domain('.domain.com') // Create Cookie // You can use: time() + 3600 etc. // You can use: '+1 day' / '+5 week' / '+2 year' etc. $cookie->set('my_cookie','my_value','+1 day'); // This cookie will be forever $cookie->forever('forever_cookie','forever_value'); // They will return 'my_value'. If cookie doens't exist, They will return False $cookie->get('my_cookie'); // You can change cookie's value $cookie->set('my_cookie','second_value'); // Delete Cookie $cookie->delete('my_cookie');
Docs
Documentation page: Cookie Docs
Licence
Contributing
- Fork it ( https://github.com/omerfdmrl/cookie/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- omerfdmrl Ömer Faruk Demirel - creator, maintainer