承接 syntactical/session 相关项目开发

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

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

syntactical/session

Composer 安装命令:

composer require syntactical/session

包简介

Bare bones drop in replacement for native PHP sessions with alternate storage repositories

README 文档

README

This library is a drop in replacement for PHP's native session handling. It exposes an interface for alternate storage repositories using the SessionHandler class introduced in 5.4.

##Usage Install the library using composer

composer install syntactical/session

##Using a PDO MySQL session store

Create the table:

CREATE TABLE `sessions` (
  `id` varchar(40) NOT NULL DEFAULT '0',
  `ip` int(10) NOT NULL DEFAULT '0',
  `user_agent` varchar(50) NOT NULL,
  `last_activity` int(10) unsigned NOT NULL DEFAULT '0',
  `data` text NOT NULL,
  PRIMARY KEY (`id`),
  KEY `last_activity` (`last_activity`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Bootstrap the library:

$db = new PDO('mysql:host=your.db.host;dbname=db','username','password');
$table = 'sessions';
$storage = new MySQLStorage($db, $table);
$handler = new Session($storage);

session_set_save_handler($handler, true);
session_start();

You can now use the $_SESSION superglobal and session_* functions as you would natively, but sessions will be stored in MySQL rather than the filesystem.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-12-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固