承接 bayfrontmedia/php-cookies 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bayfrontmedia/php-cookies

最新稳定版本:v2.0.2

Composer 安装命令:

composer require bayfrontmedia/php-cookies

包简介

Helper class to easily work with cookies.

README 文档

README

Helper class to easily and safely work with cookies.

License

This project is open source and available under the MIT License.

Author

Bayfront Media

Requirements

  • PHP ^8.0 (Tested up to 8.4)

Installation

composer require bayfrontmedia/php-cookies

Usage

get

Description:

Returns value of single $_COOKIE array key or entire array, with optional default value.

Parameters:

  • $key = NULL (string|null)
  • $default = NULL (mixed): Default value to return if the array key is not found

Returns:

  • (mixed)

Example:

use Bayfront\Cookies\Cookie;

print_r(Cookie::get());

has

Description:

Checks if $_COOKIE array key exists.

Parameters:

  • $key (string)

Returns:

  • (bool)

Example:

use Bayfront\Cookies\Cookie;

if (Cookie::has('cart_id')) {
    // Do something
}

set

Description:

Creates a cookie.

See: https://www.php.net/manual/en/function.setcookie.php

Parameters:

  • $name (string): Cookie name
  • $value (string): Cookie value
  • $minutes = 0 (int): Minutes from now until the cookie expires
  • $path = '/' (string): Path on the server in which the cookie will be available
  • $domain = '' (string): Domain/subdomain that the cookie is available to
  • $secure = true (bool): Transmit the cookie only over a secure https connection
  • $http_only = true (bool): Accessible only through the http protocol
  • $same_site = 'Lax' (string): Acceptable values of None, Lax or Strict

Returns:

  • (bool)

Example:

use Bayfront\Cookies\Cookie;

Cookie::set('cart_id', 'abc123', 60);

forget

Description:

Removes validity of cookie.

Parameters:

  • $name (string)
  • $path = '/' (string): Path on the server for the cookie to be removed

Returns:

  • (void)

Example:

use Bayfront\Cookies\Cookie;

Cookie::forget('cart_id');

forgetAll

Description:

Removes the validity of all cookies.

Parameters:

  • None

Returns:

  • (void)

Example:

use Bayfront\Cookies\Cookie;

Cookie::forgetAll();

统计信息

  • 总下载量: 1.18k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-07-27