phputil/session 问题修复 & 功能扩展

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

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

phputil/session

最新稳定版本:2.1.1

Composer 安装命令:

composer require phputil/session

包简介

A simple object-oriented wrapper to PHP's session functions.

README 文档

README

PHP's session in a object-oriented version.

Main files:

This project uses semantic versioning.

Installation

composer require phputil/session

Example 1

Setting and getting a value from the session.

$session = new phputil\FileBasedSession();
$session->start();

$session->put( 'user_name', $_POST[ 'user_name' ] ); // Set a value in the session
echo 'Hello, ', $session->get( 'user_name' ); // Get a value from the session

Example 2

Setting session cookie name and cookie duration.

$session = new phputil\FileBasedSession();
$session->setName( 'myapp' ); // (optional) "PHPSESSID" session cookie key becomes "myapp"
$session->setCookieParams( $lastOneDay = 60 * 60 * 24 ); // (optional) cookie will last one day
$session->start();

Example 3

Swapping between sessions.

$session = new phputil\FileBasedSession();

$session->start();
$savedId = $session->id();
$session->close();

// Opening another session
$session->id( $_GET[ 'another_id' ] );
$session->start(); // starts the session with id "another_id"
...
$session->close();

// Restoring the session with "savedId"
$session->id( $savedId );
$session->start();

Example 4

Regenerating the session id.

$session = new phputil\FileBasedSession();
$session->start();
$session->regenerateId( true ); // true means delete the old file

Example 5

Destroying the session.

$session = new phputil\FileBasedSession();
$session->start();
$session->destroy();

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: LGPL-3
  • 更新时间: 2015-10-22