|
楼主 |
发表于 2012-10-8 17:32:30
|
显示全部楼层
顺便贴出首页和构造函数,登陆后跳转首页时cookie内的userid值就没了~
class Start extends CI_Controller {
public $siteTitle = "网站标题";
public $keyWords = "关键字";
public $description = "网站描述";
public $islogin;
public $userid;
public $array_user = array();
function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url', 'cookie'));
$this->islogin = get_cookie('islogin',TRUE);
if($this->islogin)
{
$this->load->model('user_model');
$this->userid = get_cookie('userid',TRUE);
$this->array_user = $this->user_model->user_get($this->userid)->row_array();
}
}
public function index()//首页
{
$viewdata['siteTitle'] = $this->siteTitle;
$viewdata['keyWords'] = $this->keyWords;
$viewdata['description'] = $this->description;
$viewdata['siteHead'] = $this->siteHead();
$viewdata['siteFoot'] = $this->siteFoot();
$vd['islogin'] = $this->islogin;
$vd['array_user'] = $this->array_user;
$viewdata['loginblock'] = $this->load->view('loginblock',$vd, true);
$this->load->view('index',$viewdata);
} |
|