logifire/nano-php-state 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

logifire/nano-php-state

Composer 安装命令:

composer require logifire/nano-php-state

包简介

Session and cookie handling

README 文档

README

The purpose of this library is to bridge the PHP session implementation, and the PSR 7, 15 standards.

Add the PhpStateMiddleware to your middleware stack, and use the SessionService to start a new session instead of session_start().

You can optionally use the SessionCollection instead of $_SESSION.

...
/* @var ServerRequestInterface $server_request */
$session_service = new SessionService($server_request);

// Starts a writable session, this is the default you are used to when calling session_start()
$session_service->startWriteRead();

// Now you can use sessions 
$_SESSION['content'] = 'Hello World';

// Alternative
$session_collection = new SessionCollection();
$session_collection->setString('content', 'Hello World');
...

Cookie abstraction

This library also comes with a cookie abstraction, if you need to set custom cookies.

...
// The PhpStateMiddleware has an implicit dependency on ResponseCookieService, must be the same instance past though the app
$response_cookie_service = new ResponseCookieService();
...
$cookie = new ResponseCookie('name', 'value');
$cookie->setExpires(strtotime('+ 14 days'));

$response_cookie_service->addCookie($cookie);
...

NOTE There is no implementation of the cache_limit option. You should, however, be able to use most of the session options.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-03-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固