定制 middlewares/php-session 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

middlewares/php-session

最新稳定版本:v3.2.0

Composer 安装命令:

composer require middlewares/php-session

包简介

Middleware to start php sessions using the request data

README 文档

README

Latest Version on Packagist Software License Testing Total Downloads

Middleware to start a php session using the request data and close it after returning the response. Reads and writes session cookies in the PSR-7 request/response.

Requirements

Installation

This package is installable and autoloadable via Composer as middlewares/php-session.

composer require middlewares/php-session

Example

Dispatcher::run([ new Middlewares\PhpSession(), function () { //Use the global $_SESSION variable to get/set data $_SESSION['name'] = 'John'; } ]);

Usage

This is a middleware to start the native PHP session using the cookies of the server request.

name

The session name. If it's not provided, use the php's default name (PHPSESSID). More info session_name

// Start the session with other name $session = (new Middlewares\PhpSession())->name('user_session');

id

This option set a session id. If it's not provided, use the request's cookies to get it.

// Start the session with a specific session id $session = (new Middlewares\PhpSession())->id('foo');

options

This allows to set an of options passed to session_start()

// Start the session with a specific session id $session = (new Middlewares\PhpSession())->options([ 'cookie_lifetime' => 86400 ]);

regenerateId

This option regenerates the id after a specific time interval. The latest regeneration time is saved in the key session-id-expires but you can change it in the second argument:

// Regenerate the session id after 60 seconds $session = (new Middlewares\PhpSession())->regenerateId(60); // Regenerate the session id after 60 seconds, storing the expires date in the key 'expiresAt' $session = (new Middlewares\PhpSession())->regenerateId(60, 'expiresAt');

Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details.

The MIT License (MIT). Please see LICENSE for more information.

统计信息

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

GitHub 信息

  • Stars: 15
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固