承接 metarush/cookie-sessions 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

metarush/cookie-sessions

最新稳定版本:v3.1.0

Composer 安装命令:

composer require metarush/cookie-sessions

包简介

Storageless sessions using encrypted cookies as session handler

README 文档

README

Storageless sessions using encrypted cookies as session handler

This library is a drop-in replacement for traditional session stores like filesystem, database, memory, etc.. Use this library to leverage browser cookies as session store and gain scalability without the maintenance of traditional session stores.

Install

Install via composer as metarush/cookie-sessions

Usage

  1. Generate an encryption key by typing vendor/bin/generate-defuse-key in your terminal.

  2. Define cookie options (refer to the options parameter of the \setcookie() function).

<?php

$options = [
    'path' => '/',
    'secure' => true,
    'httponly' => true
];

Note: Don't set expires option, this library will use the session.gc_maxlifetime ini directive instead.

  1. Set the custom session handler on top of your script.
$secretKey = 'replace this with the generated key';
$cookiePrefix = 'your_identifier'; // optional cookie prefix, keep it short, alphanumeric with _ suffix (e.g., XYZ_)
$handler = new \MetaRush\CookieSessions\Handler($secretKey, $options, $cookiePrefix);
session_set_save_handler($handler, true);
session_start();
  1. Use $_SESSIONS normally
$_SESSIONS['foo'] = 'bar';

Notes

  • This library uses defuse/php-encryption for encrypting session data in cookies
  • Keep the $secretKey hidden from public
  • Browsers generally have 4,000 bytes total cookie limit per domain
  • An E_USER_WARNING will be thrown if you're trying to set a session variable that is equivalent to >= 4,000 bytes (in encrypted form)
  • The limit counts data in encrypted form which is equivalent to roughly 1,900 of unencrypted data
  • The limit doesn't account for other session data already written or scripts using cookies on the same domain
  • Minimize session/cookie variables per domain to give way to other scripts if applicable

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-04-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固