承接 phpgt/cookie 相关项目开发

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

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

phpgt/cookie

最新稳定版本:v1.0.3

Composer 安装命令:

composer require phpgt/cookie

包简介

Object oriented cookie handler.

README 文档

README

This library is an object oriented alternative to the $_COOKIE superglobal that can be read using the same associative array style code. The Cookie class represents cookie data in immutable objects, meaning that the state of the request/response cookies cannot be accidentally changed by undisclosed areas of code.

Build status Code quality Code coverage Current version PHP.Gt/Cookie documentation

Example usage

// Create a replacement for $_COOKIE.
$cookie = new Gt\Cookie\CookieHandler($_COOKIE);

// Access values as normal.
$value = $cookie["firstVisit"];

if(isset($cookie["firstVisit"])) {
// Cookie "firstVisit" exists.
}

if($cookie->has("firstVisit")) {
// Cookie "firstVisit" exists.
}
else {
// Create a new cookie that expires in ten days.
	$now = new DateTime();
	$expire = new DateTime("+10 days");
	$cookie->set("firstVisit", $now, $expire);
}

// Now you can unset the superglobal!

What's not covered?

This library does not touch on encrypting cookies. To store sensitive information across HTTP requests, use a session variable. To ensure cookies can't be read by JavaScript, use a secure HTTP-only cookie.

Proudly sponsored by

JetBrains Open Source sponsorship program

JetBrains logo.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-01-15