本文整理汇总了PHP中CommonController::sess方法的典型用法代码示例。如果您正苦于以下问题:PHP CommonController::sess方法的具体用法?PHP CommonController::sess怎么用?PHP CommonController::sess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommonController
的用法示例。
在下文中一共展示了CommonController::sess方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ecshop_init
protected function ecshop_init()
{
header('Cache-control: private');
header('Content-type: text/html; charset=utf-8');
$shop_closed = C('shop_closed');
if (!empty($shop_closed)) {
$close_comment = C('close_comment');
$close_comment = empty($close_comment) ? 'closed.' : $close_comment;
exit($close_comment);
}
//NULL
// 初始化session
self::$sess = new EcsSession(self::$db, self::$ecs->table('sessions'), self::$ecs->table('sessions_data'), 'ecsid');
define('SESS_ID', self::$sess->get_session_id());
// 创建 Smarty 对象
self::$view = new EcsTemplate();
self::$view->cache_lifetime = C('cache_time');
self::$view->template_dir = ROOT_PATH . 'themes/' . C('template');
self::$view->cache_dir = ROOT_PATH . 'data/cache/caches';
self::$view->compile_dir = ROOT_PATH . 'data/cache/compiled';
if ((DEBUG_MODE & 2) == 2) {
self::$view->direct_output = true;
self::$view->force_compile = true;
} else {
self::$view->direct_output = false;
self::$view->force_compile = false;
}
self::$view->caching = true;
// 会员信息
self::$user = init_users();
if (empty($_SESSION['user_id'])) {
if (self::$user->get_cookie()) {
// 如果会员已经登录并且还没有获得会员的帐户余额、积分以及优惠券
if ($_SESSION['user_id'] > 0 && !isset($_SESSION['user_money'])) {
model('Users')->update_user_info();
}
} else {
$_SESSION['user_id'] = 0;
$_SESSION['user_name'] = '';
$_SESSION['email'] = '';
$_SESSION['user_rank'] = 0;
$_SESSION['discount'] = 1.0;
}
}
// 判断是否支持gzip模式
if (gzip_enabled()) {
ob_start('ob_gzhandler');
}
// 设置推荐会员
if (isset($_GET['u'])) {
set_affiliate();
}
// session不存在,检查cookie
if (!empty($_COOKIE['ECS']['user_id']) && !empty($_COOKIE['ECS']['password'])) {
// 找到cookie,验证信息
$where['user_id'] = $_COOKIE['ECS']['user_id'];
$where['password'] = $_COOKIE['ECS']['password'];
$row = $this->model->table('users')->field('user_id, user_name, password')->where($where)->find();
if ($row) {
$_SESSION['user_id'] = $row['user_id'];
$_SESSION['user_name'] = $row['user_name'];
model('Users')->update_user_info();
} else {
// 没有找到这个记录
$time = time() - 3600;
setcookie("ECS[user_id]", '', $time, '/');
setcookie("ECS[password]", '', $time, '/');
}
}
// search 关键词
$search_keywords = C('search_keywords');
if (!empty($search_keywords) && is_string($search_keywords)) {
$keywords = explode(',', $search_keywords);
$this->assign('hot_search_keywords', $keywords);
}
// 模板替换
defined('__TPL__') or define('__TPL__', __ROOT__ . '/themes/' . C('template'));
$stylename = C('stylename');
if (!empty($stylename)) {
$this->assign('ectouch_css_path', __ROOT__ . '/themes/' . C('template') . '/css/ectouch_' . C('stylename') . '.css');
} else {
$this->assign('ectouch_css_path', __ROOT__ . '/themes/' . C('template') . '/css/ectouch.css');
}
}