Home >CMS Tutorial >PHPCMS >How does phpcms determine whether the user is logged in?
How phpcms determines whether the user is logged in:
First get the userid
<?php $userid= param::get_cookie('_userid'); ?>
and then determine whether it is empty
{if $userid} 。。。这里写已经登录之后的代码。。。 {else} {/if}
phpcms determines whether the user is logged in. The implementation code is in index.php of phpcms/modules/member/:
<?php 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').'<a href="'.APP_PATH.'member-account_manage_avatar.html" target="_blank">;<img style="display:inline;vertical-align: middle;padding:1px;width:16px;height:16px;border-radius:100%;border:1px solid #dedede;" src="'.get_memberavatar($_userid,1,30).'" width="16" height="16" onerror="this.src=\''.IMG_PATH.'member/nophoto.gif\'">;</a>; '.get_nickname().' 欢迎回家 <a href="'.APP_PATH.'member-index.html" target="_blank">;'.L('member_center').'</a>; | <a href="'.APP_PATH.'member-fabu.html" target="_top" class="upv_btn">;发布信息</a>; | <a href="'.APP_PATH.'member-logout.html">;'.L('logout').'</a>;'; $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); } } ?>
PHP Chinese website, a large number of free PHPCMS tutorials, welcome Online Learning!
The above is the detailed content of How does phpcms determine whether the user is logged in?. For more information, please follow other related articles on the PHP Chinese website!