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

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

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

kecik/session

最新稳定版本:1.0.3

Composer 安装命令:

composer require kecik/session

包简介

Session Libraries for Kecik Framework

README 文档

README

A library created specifically for Kecik Framework, this library was made to facilitate the use session on project we build. This library also supports data encryption so that we secure the data session.

Installation

Add the following line to the file composer.json located on the project we want to build.

{
    "require": {
        "kecik/kecik": "1.0.2-alpha",
        "kecik/session": "dev-master"
    }
}

Next, run the command

composer update

And wait until the update process is completed without error.

Note: This library requires Kecik Framework, so we need to install Kecik Framework first, then we can install this library.

How to use Session Library

<?php
require "vendor/autoload.php";

$app = new Kecik\Kecik();
$session = new Kecik\Session($app);

Whereas if you want the session in an encrypted then we simply add the config encryption

<?php
require "vendor/autoload.php";

$app = new Kecik\Kecik();

//Config untuk enkripsi session
$app->config->set('session.encrypt', TRUE);
$session = new Kecik\Session($app);

id()

This Function/Method use for get session id. Example:

<?php
require "vendor/autoload.php";

$app = new Kecik\Kecik();
$session = new Kecik\Session($app);
echo $session->id();

newId()

This Function/Method use to make new session id. Example:

<?php
require "vendor/autoload.php";

$app = new Kecik\Kecik();
$session = new Kecik\Session($app);
echo 'ID SESSION: '.$session->id().'<br />';
echo 'NEW ID SESSION: '.$session->newId().'<br />';

set()

This Function/Method use for create/update a session.

set(string $name, mixed $value)

Example:

<?php
require "vendor/autoload.php";

$app = new Kecik\Kecik();
$session = new Kecik\Session($app);
$session->set('integer', 123);
$session->set('string', 'satu dua tiga');
$session->set('array', array('satu', 'dua', 'tiga'));

get()

This Function/Method for get a value from a session.

get(string $name)

Example:

<?php
require "vendor/autoload.php";

$app = new Kecik\Kecik();
$session = new Kecik\Session($app);
$session->set('integer', 123);
$session->set('string', 'satu dua tiga');
$session->set('array', array('satu', 'dua', 'tiga'));

echo 'session Integer: '.$session->get('integer').'<br />';
echo 'session String: '.$session->get('string').'<br />';
echo 'Session Array: ';
print_r($session->get('array'));

delete()

This Function/Method use for delete a session.

delete(string $name)

Example:

<?php
require "vendor/autoload.php";

$app = new Kecik\Kecik();
$session = new Kecik\Session($app);
$session->set('kecik_session', 'ini nilai session nya');

echo 'kecik_session: '.$session->get('kecik_session').'<br />';

$session->delete('kecik_session');
echo 'kecik_session: '.$session->get('kecik_session').'<br />';

clear()

This Function/Method use for delete all session are exist. Example:

<?php
require "vendor/autoload.php";

$app = new Kecik\Kecik();
$session = new Kecik\Session($app);

$session->clear();

setExpire()

This Function/Method use for setting expiry from session.

setExpire(int $minute);

Example:

<?php
require "vendor/autoload.php";

$app = new Kecik\Kecik();
$session = new Kecik\Session($app);

$session->setExpire(60);  //session akan kadarluarsa setelah 60 menit/1 jam

getExpire()

This Function/Method use for get value expiry session. Example:

<?php
require "vendor/autoload.php";

$app = new Kecik\Kecik();
$session = new Kecik\Session($app);
echo $session->getExpire();

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-22