#How to determine whether the user is logged in in phpcms?
First get the "_userid" data by using the "get_cookie()" method in the "param" class; then assign it to a new variable; finally use PHP syntax or "if" in the template Label, just judge the new variable.
Sample code
<?php $userid= param::get_cookie('_userid'); ?>
{if $userid} 。。。这里写已经登录之后的代码。。。 {else} 。。。这里写已经登录之后的代码。。。 {/if}
defined('IN_PHPCMS') or exit('No permission resources.'); class MY_index extends index { private $times_db; public function __construct() { parent::__construct(); } public function top_mini() { $_username = param::get_cookie('_username'); $_userid = param::get_cookie('_userid'); $siteid = isset($_GET['siteid']) ? intval($_GET['siteid']) : ''; $jsoncallback=isset($_GET['jsoncallback']) ? $_GET['jsoncallback'] : ''; //定义站点id常量 if (!defined('SITEID')) { define('SITEID', $siteid); } if($_username){ $res["success"]=1; $res["message"]=' '.L('hellow').';;; '.get_nickname().' 欢迎回家 ;'.L('member_center').'; | ;发布信息; | ;'.L('logout').';'; $res["message"] = pc_base::load_config('system', 'charset') == 'gbk' ? iconv('utf-8', 'utf-8', $res["message"]) : $res["message"]; //get_nickname();//, } else{ $res["success"]=0; } if($jsoncallback){ echo $jsoncallback . "({\"items\":[".json_encode($res)."]})"; }else{ echo json_encode($res); } //echo json_encode($res); } } ?>
Recommended tutorials: "PHP" "PHPCMS Tutorial"
The above is the detailed content of How to determine whether the user is logged in in phpcms?. For more information, please follow other related articles on the PHP Chinese website!