Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tomkyle/cookies

A small PHP library for dealing with cookies
https://github.com/tomkyle/cookies

Last synced: about 12 hours ago
JSON representation

A small PHP library for dealing with cookies

Awesome Lists containing this project

README

        

#Cookies

Small and simple PHP library for dealing with cookies.

[![Build Status](https://travis-ci.org/tomkyle/Cookies.svg?branch=master)](https://travis-ci.org/tomkyle/Cookies)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/tomkyle/Cookies/badges/quality-score.png?s=e1e8eaac2d69db9564c723d289bea895e1976bb9)](https://scrutinizer-ci.com/g/tomkyle/Cookies/)
[![Coverage Status](https://coveralls.io/repos/tomkyle/Cookies/badge.png?branch=master)](https://coveralls.io/r/tomkyle/Cookies?branch=master)

##Set cookie
```php
setExpiration( new \DateTime( "14day" ));

// Fire cookie:
new SendCookie( $c1 );

// Another example
$c2 = new Cookie( "any", "val", new \DateTime( "tomorrow" ) );
new SendCookie( $c2 );

// Delete from HTTP and $_COOKIE:
new UnsetCookie( $c2 );
```

##Retrieve cookie
```php
getValue(); // outputs "bar"
```

##Installation via Composer

This library has no dependencies. Install from command line or `composer.json` file:

#####Command line

composer require tomkyle/cookies

#####composer.json
"require": {
"tomkyle/cookies": "dev-master"
}

##Classes Overview

- *interface* CookieInterface
- *abstract* CookieAbstract
- Cookie *extends* CookieAbstract
- RequestCookie *extends* CookieAbstract
- SendCookie
- UnsetCookie

##Supported Attributes

- Cookie name
- Cookie value
- Expiration/Life time
- **Not supported:** Path
- **Not supported:** Domain
- **Not supported:** Secure (HTTPS only)
- **Not supported:** http-only protection

[PHP documentation on setcookie](http://www.php.net/manual/en/function.setcookie.php)

##Testing

Simply issue `phpunit` to run the test suites; you may have to `composer update`first.