Download the PHP package dasprid/pikkuleipa without Composer
On this page you can find all versions of the php package dasprid/pikkuleipa. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package pikkuleipa
Pikkuleipa
Pikkuleipa is a cookie manager for PSR-7 compliant applications, utilizing JSON Web Tokens for security and allowing the handling of multiple independent cookies.
Installation
Install via composer:
Getting started (for Expressive)
Import the factory config
Create a file named pikkuleipa.global.php
or similar in your autoloading config directory:
This will introduce a few factories, namely you can retrieve the following objects through that:
DASPRiD\Pikkuleipa\CookieManager
throughDASPRiD\Pikkuleipa\CookieManagerInterface
DASPRiD\Pikkuleipa\TokenManager
throughDASPRiD\Pikkuleipa\TokenManagerInterface
Configure Pikkuleipa
For Pikkuleipa to function, it needs a few configuration variables. Copy the file doc/example-config.php
and adjust the
values as needed.
Using the cookie manager
The token manager should usually not be of interest to you. The important part is the cookie manager, which you can either use through the container, if you are using PSR/Container, or by other means. It concretely gives you three actions you can do, which are setting cookies, getting cookies and expiring cookies.
Setting cookies
Setting a cookie is really easy. First you either get an existing cookie from the cookie manager or you create a new one. Then you set that cookie on a PSR-7 response and return the modified response to the user.
The setCookie
method takes two additional parameters beside the response and the cookie. The first one is whether the
cookie should expire at the end of the browser session, which defaults to false. The second one defines whether the
setCookie
call should override a previous expireCookie
call, which defaults to true.
Getting cookies
Getting cookies is also quite simple. When retrieving a cookie, the cookie- and the token manager will verify that the cookie exists and its contents are legit. If something fails, a new empty cookie instance is returned.
Expiring cookies
Expiring cookies is just as simple as setting a cookie. You can either expire a cookie by its instance or by name:
About the name
Pikkuleipa is the Finnish word for "cookie" or "biscuit", nothing fancy here!
All versions of pikkuleipa with dependencies
lcobucci/jwt Version ^3.2
psr/http-message Version ^1.0
dflydev/fig-cookies Version ^1.0|^2.0
cultuurnet/clock Version ^1.0