|
楼主 |
发表于 2012-12-6 19:04:27
|
显示全部楼层
本帖最后由 veicn 于 2012-12-6 19:07 编辑
Hex 发表于 2012-12-6 18:33
$this->data 从哪里赋值的啊? 在这里赋的值,调试的时候发现get_cookie ( md5 ( 'User__cms' ) ); 和 $this->session->userdata ( md5 ( 'User__cms' ) ) 取到的值都是 flase,赋值的时候都赋上了 set_cookie ( md5 ( 'User__cms' ), md5 ( $params ) );和 $this->session->set_userdata ( md5 ( 'User__cms' ), md5 ( $params ) ); 取得时候都是空的。
<?php if (! defined ( 'BASEPATH' )) exit ( 'No direct script access allowed' );
class Bl_userlib extends CI_Model {
function __construct() {
parent::__construct();
$this->data ['cookie'] = get_cookie ( md5 ( 'User__cms' ) );
$this->data ['session'] = $this->session->userdata ( md5 ( 'User__cms' ) );
}
function result($param = false) {
if ($param === false) {
if (! empty ( $this->data ['cookie'] ) && ! empty ( $this->data ['session'] )) {
if ($this->data ['cookie'] == $this->data ['session']) {
echo '<script language="javascript">top.location="' . site_url ( 'panel/index' ) . '";</script>';
}
}
} else {
if (empty ( $this->data ['cookie'] ) && empty ( $this->data ['session'] )) {
echo '<script language="javascript">top.location="' . site_url ( 'panel/login' ) . '";</script>';
}
}
}
function seting($param = false, $params = '') {
if ($param === false) {
set_cookie ( md5 ( 'User__cms' ), md5 ( $params ) );
$this->session->set_userdata ( md5 ( 'User__cms' ), md5 ( $params ) );
} else {
delete_cookie ( md5 ( 'User__cms' ) );
$this->session->unset_userdata ( md5 ( 'User__cms' ) );
}
}
}
?> |
|