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 src="/static/imghwm/default1.png" data-src="'.get_memberavatar($_userid,1,30).'" class="lazy" style="max-width:90%" style="max-width:90%" style="max-width:90%" onerror="this.src=\''.IMG_PATH.'member/nophoto.gif\'" alt="How does phpcms determine whether the user is logged in?" >;</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!

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

SublimeText3 English version
Recommended: Win version, supports code prompts!

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Mac version
God-level code editing software (SublimeText3)

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.

Atom editor mac version download
The most popular open source editor