本文整理汇总了PHP中SessionHandler::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionHandler::instance方法的具体用法?PHP SessionHandler::instance怎么用?PHP SessionHandler::instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SessionHandler
的用法示例。
在下文中一共展示了SessionHandler::instance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
public static function get($name)
{
if (!SessionHandler::instance()->hasSession()) {
return null;
}
return self::instance()->getSession()->get($name);
}
示例2: save
public static function save()
{
try {
MessageHandler::instance()->save();
SessionHandler::instance()->save();
} catch (Exception $e) {
//Do nothing...
}
}
示例3: hasAccess
public function hasAccess($tag)
{
$entry = $this->tagRoles[strtoupper($tag)];
if (!$entry) {
return true;
}
$user = SessionHandler::instance()->getUser();
return $entry->isValid($user ? $user->getRole() : self::R_GUEST);
}
示例4: loadFromSID
public function loadFromSID($SID)
{
$result = CouchDB::client()->key($SID)->include_docs(true)->getView("session", 'all');
if (count($result->rows) > 0) {
$this->document = current($result->rows)->doc;
}
if (!$this->document) {
$this->document = new stdClass();
}
$this->document->SID = $SID;
$this->document->type = 'session';
$this->document->expires = SessionHandler::instance()->getExpires();
return $this;
}
示例5: register
public function register()
{
$this->validate(array('name' => 'required,min(2)', 'email' => 'required,email', 'password' => 'required,min(4)', 'password2' => 'required,min(4),equal(password)'));
$userDoc = Request::post()->get('name', 'email', 'password');
$userDoc->password = md5($userDoc->password);
$userDoc = UserService::save($userDoc);
if (!$userDoc) {
MessageHandler::instance()->addError('E-mail was already registered - forgot your password?');
return;
}
$user = new UserModel($userDoc);
SessionHandler::instance()->setUser($user);
MessageHandler::instance()->addMessage('You were successfully registered and logged in');
$this->redirect();
}
示例6: define
<?php
define('BASEURL', dirname($_SERVER['SCRIPT_NAME']) . '/');
require_once 'settings.php';
//Init session
SessionHandler::instance()->setSessionKey('SCRUMSID');
SessionHandler::instance()->setSession(new SessionModel());
SessionHandler::instance()->setExpires(3600 * 24 * 7);
SessionHandler::instance()->init();
//Init pimple
Pimple::instance()->run();