Skip to content

PHP library for handling cookies especially created for WPEngine hosted sites

License

Notifications You must be signed in to change notification settings

WPDiggerStudio/WPCookie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WPCookie

PHP library for handling cookies especially created for WPEngine hosted sites



Requirements

This library is supported by PHP versions 5.6 or higher.

Installation

The preferred way to install this extension is through Composer.

To install WPCookie library, simply:

$ composer require WPDiggerStudio/WPCookie

You can also clone the complete repository with Git:

$ git clone https://github.com/WPDiggerStudio/WPCookie.git

Available Methods

Available methods in this library:

- Set cookie:

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 100

# Return (boolean)

- Get item from cookie:

Cookie::get($key);
Attribute Description Type Required Default
$key Cookie name. string No ''

# Return (mixed|false) → returns cookie value or false

- Extract item from cookie and delete cookie:

Cookie::destroy($key);
Attribute Description Type Required Default
$key Cookie name to destroy. Not set to delete all. string No ''

# Return (boolean)

- Set cookie prefix:

Cookie::setPrefix($prefix);
Attribute Description Type Required Default
$prefix Cookie prefix. string Yes

# Return (boolean)

- Get cookie prefix:

Cookie::getPrefix();

# Return (string) → cookie prefix


- Set cookie domain:

Cookie::setDomain($domain);
Attribute Description Type Required Default
$domain Cookie domain. string Yes

# Return (boolean)

- Get cookie domain:

Cookie::getDomain();

# Return (string) → cookie domain

- Set cookie secure:

Cookie::setSecure($secure);
Attribute Description Type Required Default
$secure Cookie secure. string Yes

# Return (boolean)

- Get cookie secure:

Cookie::getSecure();

# Return (string) → cookie secure

- Set cookie httpOnly:

Cookie::setHttpOnly($httpOnly);
Attribute Description Type Required Default
$httpOnly Cookie httpOnly. string Yes

# Return (boolean)

- Get cookie httpOnly:

Cookie::getHttpOnly();

# Return (string) → cookie httpOnly

Quick Start

To use this class with Composer:

require __DIR__ . '/vendor/autoload.php';

use WPDiggerStudio\WPCookie\WPCookie;

Or If you installed it manually, use it:

require_once __DIR__ . '/WPCookie.php';

use WPDiggerStudio\WPCookie\WPCookie;

Usage

Example of use for this library:

- Set cookie:

Cookie::set('cookie_name', 'value', 100);

- Get cookie:

Cookie::get('cookie_name');

- Get all cookies:

Cookie::get('all');

- Destroy one cookie:

Cookie::destroy('cookie_name');

- Set cookie prefix:

Cookie::setPrefix('prefix_');

- Get cookie prefix:

Cookie::getPrefix();

License

This project is licensed under MIT license. See the LICENSE file for more info.

Copyright

WPDiggerStudio, wpdigger.com

If you find it useful, let me know 😉

You can contact me through my email.

About

PHP library for handling cookies especially created for WPEngine hosted sites

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages