PHP code example of caichuanhai / session
1. Go to this page and download the library: Download caichuanhai/session library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
caichuanhai / session example snippets
use caichuanhai\session;
$session = new session([$config]);
array(
'session_name' => 'CCHSESSION',
'session_path' => '/',
'session_match_ip' => false,
'session_expire' => 3600*24
)
$session->setConfig($name, $value);
$session->getConfig([$name]);
$session->setDriver('redis', $config);
//$config配置为
$config = array(
'host' => '127.0.0.1',
'port' => 6379,
'password' => null,
'database' => null
)
$session->setDriver('predis', $config);
//$config配置为
$config = array(
'host' => '127.0.0.1',
'port' => 6379,
'password' => null,
'database' => null
)
$session->setDriver('memcache', $config);
//$config配置为
$config = array(
'host' => '127.0.0.1',
'port' => 11211,
//'sasl_user' => false,
//'sasl_password' => false
)
$session->setDriver('memcached', $config);
//$config配置为
$config = array(
'host' => '127.0.0.1',
'port' => 11211,
//'sasl_user' => false,
//'sasl_password' => false
)
$session->setDriver('mongodb', $config);
//$config配置为
$config = array(
'host' => '127.0.0.1',
'port' => 27017,
'username' => '',
'password' => '',
'timeout' => 1,
'collectionName' => 'Cache',
'databaseName' => 'database'
)
$session->setDriver('files', $config);
$session->item([$item]);
$session->set($item, $value);
$session->unset($item, $value);
$session->destroy();