在 CLI 上使用 PHP 内置会话管理器

v0.1 2017-01-20 19:40 UTC

This package is not auto-updated.

Last update: 2024-09-28 20:03:49 UTC


README

此库提供了一种命令行和面向对象的 php 标准会话管理版本。在包装器内部,它使用默认的 php session_*-命令

如果您在安装或使用过程中有任何问题或疑问,请 创建一个问题

安装

要使用 composer 安装此库,请在控制台运行以下命令

composer require insulinjunkiede/clisession

或者将包手动添加到您的 composer.json 文件的 require 部分

"insulinjunkiede/clisession": "dev-master"

使用示例

$session = new InsulinJunkieDe\CliSession\Session('.session', __DIR__);
/*
When creating a new session, the first parameter takes the file name and the 2nd
one the directory where is file should be written to.
Both an be omitted, but it won't work, since PHP is generating a new
session_id(and filename) each time you restart your CLI script.
So the first paramater is kind of mandatory, when you want to reuse the
session-content in the next CLI-call
*/
$session->setParam('key','value');
$session->getParam('key');