本文整理汇总了PHP中cookie::item方法的典型用法代码示例。如果您正苦于以下问题:PHP cookie::item方法的具体用法?PHP cookie::item怎么用?PHP cookie::item使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cookie
的用法示例。
在下文中一共展示了cookie::item方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
parent::__construct();
$authID = session::item('auth_id');
$userID = session::item('user_id');
$ipaddress = substr(input::ipaddress(), 0, 15);
$useragent = substr(input::useragent(), 0, 255);
$user = array();
if ($authID && ($user = $this->getSession($authID, $userID, $ipaddress, $useragent))) {
if ($user['active_date'] < date_helper::now() - 60 * $this->timeout) {
$this->saveSession($authID, $userID, $ipaddress, $useragent);
if (isset($user['user_id']) && $user['user_id']) {
$this->saveLastvisit($user['user_id']);
}
}
} else {
$cookie = cookie::item('sessdata');
$cookie = $cookie ? @json_decode($cookie, true) : array();
if ($cookie && is_array($cookie)) {
$userID = isset($cookie['user_id']) ? $cookie['user_id'] : '';
$email = isset($cookie['email']) ? $cookie['email'] : '';
$passhash = isset($cookie['passhash']) ? $cookie['passhash'] : '';
if ($userID && is_numeric($userID) && $userID > 0) {
if ($user = $this->getUser($userID, false, false)) {
$newPasshash = $this->generatePasshash($email, $user['password']);
if ($user['active'] && $user['verified'] && strcmp($email, $user['email']) == 0 && strcmp($passhash, $newPasshash) == 0) {
$authID = $this->saveSession(0, $user['user_id'], $ipaddress, $useragent);
$this->saveLastvisit($user['user_id']);
} else {
$user = array();
}
}
}
}
}
if (!$user || !isset($user['user_id']) || !$user['user_id'] || !$this->createUserSession($user)) {
$userID = 0;
if (!$user) {
$authID = $this->saveSession(0, $userID, $ipaddress, $useragent);
}
$this->createGuestSession();
}
session::set('auth_id', $authID);
session::set('user_id', $userID);
// Is the site offline?
if (!input::isCP() && !config::item('site_online', 'system') && !session::permission('site_access_offline', 'system') && uri::getURI() != 'site/offline' && uri::segment(1) != 'load') {
router::redirect('site/offline');
} elseif (input::isCP() && !session::permission('site_access_cp', 'system') && (uri::getURI() != 'cp' && uri::getURI() != 'cp/users/login' && uri::getURI() != 'cp/users/login/license')) {
router::redirect('cp/users/login');
}
if (!input::isCP() && $this->isLoggedin() && session::permission('site_access_cp', 'system') && uri::segment(1) != 'load' && input::demo(0, '', session::item('user_id'))) {
$this->logout();
view::setInfo('For the purposes of this demo you may not use front end of the site under the administrator account. As such we have now logged you out.<br/>Feel free ' . html_helper::anchor('users/signup', 'register on the site') . ' to test user end functionality or ' . html_helper::anchor('users/login', 'login') . ' using your existing account details if you have one already.');
router::redirect();
}
}