Download the PHP package mmdm/sim-cookie without Composer

On this page you can find all versions of the php package mmdm/sim-cookie. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sim-cookie

Simplicity Cookie

A library for cookie management.

Features

Install

composer

Or you can simply download zip file from github and extract it, then put file to your project library and use it like other libraries.

Just add line below to autoload files:

and you are good to go.

How to use

Use with Crypt library

If you need more security on cookies, use Crypt library.

If you don't need some of your cookies to be secure, pass false as last parameter of setValue of ISetCookie method.

Available methods

Cookie

parse(string $cookie_string, bool $decode = false, bool $encrypt = true): ?ISetCookie

Send a cookie string to parse it into SetCookie object or null if it can't parse.

Note:

To decode value of parsed string, pass true to $decode parameter.

To encrypt parsed value, pass true as $encrypt parameter.

Parameter Type Default
$cookie_string ISetCookie
$decode bool false
$encrypt bool true

set(string $name): ISetCookie

Create new cookie object and can modify all inputs after set method.

Please refer to SetCookie Available Methods for more information.

get(?string $name = null, $prefer = null)

Get cookie's value or $prefer if not defined.

Note

To get all cookies, do not send any parameter.

getAsString(?string $name = null, bool $decode = true, bool $decrypt = false): string

Get string for a cookie.

Note

To get all cookies as string, send null as $name

remove(string $name): ICookie

Remove a cookie(event from $_COOKIE variable).

has(string $name): bool

Check if there is cookie with specific name.

getCookieValueFromString(string $str)

Get(decrypted) value.

Note

It is useful when there is a cookie value is inside a header and want get actual value and check it.


SetCookie Available Methods

getName(): ?string

Get cookie name.

setValue(?string $value, bool $encrypt = true): ISetCookie

Set value of cookie.

Note

To encrypt value pass true as second parameter.

getValue(): string

Get cookie value.

setExpiration($expire): ISetCookie

Set expiration to cookie.

getExpiration(): int

Get expiration of cookie.

setPath(?string $path): ISetCookie

Set cookie path.

getPath(): ?string

Get cookie path.

setDomain(?string $domain): ISetCookie

Set domain of cookie.

getDomain(): ?string

Get cookie domain.

setSecure(?bool $answer): ISetCookie

Set secure string to cookie.

isSecure(): ?bool

Check if secure string set or not.

setHttpOnly(?bool $answer): ISetCookie

Set httponly string to cookie.

isHttpOnly(): ?bool

Check if httponly set or not.

setSameSite(?string $same_site): ISetCookie

Set same site for modern browsers.

Note

Acceptable values are:

getSameSite(): ?string

Get samesite if set before or null.

setExtra(string $extra): ISetCookie

Set extra string for cookie (if needed and supported).

getExtra(): string

Get extra cookie string

setUseragent(?string $useragent = null): ISetCookie

Set useragent for check against to see if it support samesite or not.

Note

By default it'll get browser from $_SERVER.

getUseragent(): ?string

Get useragent.

Note

This method will return the useragent you set not useragent from $_SERVER variable.

toString(bool $decode = true, bool $decrypt = false): string

Get cookie header of this cookie as string

Example of output:

save(bool $encode = true): bool

Save configured cookie. $encode will encode value.

Note

You MUST call this method to save cookie otherwise you missed your cookie.

Dependencies

There is just one dependency and it is Crypt library. With this feature, if any cookie hijacking happens, they can't see actual data because it is encrypted.

License

Under MIT license.


All versions of sim-cookie with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
mmdm/sim-crypt Version ^1.0
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mmdm/sim-cookie contains the following files

Loading the files please wait ....