定制 krubio/perfect-session 二次开发

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

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

krubio/perfect-session

最新稳定版本:v0.1.0

Composer 安装命令:

composer require krubio/perfect-session

包简介

Session Handling

README 文档

README

codecov CodeFactor codebeat badge Maintainability Scrutinizer Code Quality Build Status Code Intelligence Status

Bugs Security Rating Maintainability Rating Vulnerabilities Quality Gate Status Duplicated Lines (%) Technical Debt Code Smells Reliability Rating

Session Class

The Session class provides a simple and convenient way to manage PHP sessions.

Usage

To use the Session class, create an instance of it and call its methods to get, set, or delete session data.

use PerfectApp\Session\Session;

// Create a new session object
$session = new Session();

// Set a session variable
$session->set('username', 'johndoe');

// Get a session variable
$username = $session->get('username');

// Delete a session variable
$session->delete('username');

By default, the Session class uses the $_SESSION superglobal to store session data. You can also pass an array of session data to the constructor if you want to use a different session data source.

// Create a session object using a custom session data array
$sessionData = [
    'username' => 'johndoe',
    'email' => 'johndoe@example.com',
];

$session = new Session($sessionData);

// Get a session variable
$username = $session->get('username');

// Delete a session variable
$session->delete('username');

Methods

__construct(array|null $sessionData = null)

Creates a new Session object.

Parameters

  • $sessionData (optional): An array of session data to use instead of $_SESSION.

get(string $key): mixed|null

Gets a session variable by key.

Parameters

  • $key: The name of the session variable to get.

Returns

The value of the session variable, or null if the variable does not exist.

set(string $key, mixed $value): void

Sets a session variable by key.

Parameters

  • $key: The name of the session variable to set.
  • $value: The value to assign to the session variable.

delete(string $key): void

Deletes a session variable by key.

Parameters

  • $key: The name of the session variable to delete.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-03-28