aeforge/session

AEForge Session 组件。提供跨应用处理会话的方法

V1.0.0 2023-10-27 04:29 UTC

This package is auto-updated.

Last update: 2024-09-27 06:17:23 UTC


README

AEForge Session 组件。提供跨应用处理会话的方法。

安装

通过composer安装

  composer require aeforge/session

克隆项目

    https://github.com/aeforge/Session.git

使用/示例

示例

use Aeforge\Session\Session;

// Start a new session instance
$session = new Session();
// Add expiring time to 60 (in minutes)
$session->register(60);
//Set a normal session key and value
$session->set("session_key", "session_value");
//Set a flashed session key and value (useful for forms errors for example)
$session->flash("flashed_key", "flashed_value");
// Get a normal session value using a key
echo $session->get("hello");
//Get a flashed session value using a key
echo $session->getFlashed("hello");
// Clears both the flash session array and the data session array(normal session)
$session->clear();
// Clear the data array only(normal session)
$session->clearData();
// Clear the flashed array only
$session->clearFlashed();
// Ends the session
$session->destroy();
// Regenerates the session id
$session->regenerate();
// Check if the session expired
$session->isExpired ();