#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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Chinese version
Chinese version, very easy to use

Notepad++7.3.1
Easy-to-use and free code editor