Skip to content

This library aims to make cookies easier to manage and a little bit more secure. It signs cookies with a (secret) salt and prevents data from being modified by the user.

License

Notifications You must be signed in to change notification settings

InitPHP/Cookies

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

InitPHP Cookies Manager

This library aims to make cookies easier to manage and a little bit more secure. It signs cookies with a (secret) salt and prevents data from being modified by the user.

Requirements

Installation

composer require initphp/cookies

Configuration

$options = [
        'ttl'       => 2592000, // 30 days
        'path'      => '/',
        'domain'    => null,
        'secure'    => false,
        'httponly'  => true,
        'samesite'  => 'Strict'
];

Usage

require_once __DIR__ . "/vendor/autoload.php";
use InitPHP\Cookies\Cookie;

$cookie = new Cookie('cookie_name', 's£cr£t_s@lt', []);
$cookie->set('username', 'sdd');

Methods

public function has(string $key): bool;

public function get(string $key, $default = null): mixed;

public function pull(string $key, $default = null): mixed;

public function set(string $key, string|bool|int|float $value, ?int $ttl = null): self;

public function setArray(string[] $assoc, ?int $ttl = null): self;

public function remove(string ...$key): bool;

public function push(set $key, string|bool|int|float $value, ?int $ttl = null): string|bool|int|float;

public function all(): array;

public function flush(): bool;

public function destroy(): bool;

Credits

License

Copyright © 2022 MIT License

About

This library aims to make cookies easier to manage and a little bit more secure. It signs cookies with a (secret) salt and prevents data from being modified by the user.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages