Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of judging whether a user is logged in by phpcms v9

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the method of judging whether a user is logged in by phpcms v9, which has a certain reference value and can be used for reference by friends who need it. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.

Phpcms v9 determines whether the user is logged in? Phpcms V9 how to determine whether a user logs in or not and the problem of label writing after login

The first step is to get the userid

{php$userid=param::get_cookie ('_ userid');}

Then determine whether it is empty or not.

{if $userid}. The code after login is written here. {else} . The code after login is written here. {/ if}

Got it.

If you want to extend more functions, such as the ability to view contact information after login, we need to declare a variable to control the return page after login.

$forward = trim ($url)

Code when not logged in

Log in to view contact information

Note that there should be a parameter forward= {urlencode ($url)} in the link address so that the user can successfully return to the previous content page after logging in.

Complete code

{php$userid=param::get_cookie ('_ userid'); $forward=trim ($url);} {if$userid}

Content after login

{else}

Log in to view contact information

{/ if}

But if we want to achieve it on the home page, it won't work with this method, because the home page is static, we can do it by writing a method.

Open / phpcms/modules/content/index.php add

/ / Home user logs in to publicfunctionmember () {$_ username=param::get_cookie ('_ username'); $_ userid=param::get_cookie ('_ userid'); $siteid=isset ($_ GET ['siteid'])? intval ($_ GET [' siteid']):''; / / defines the site id constant if (! defined ('SITEID')) {define (' SITEID',$siteid);} $snda_enable=pc_base::load_config ('system','snda_enable') Includetemplate ('member','afterlogin');}

The method name can be defined according to the actual situation. Then increase the location that needs to be displayed on the home page template

< script type="text/javascript">

[xss_clean] ('

< iframe src="{APP_PATH}index.php?m=content&c=index&a=member&forward='+encodeURIComponent(location.href)+'&siteid={get_siteid()}" allowTransparency="true" width="125" height="98" frameborder="0" scrolling="no">

< /iframe>

')

< /script>

Thank you for reading this article carefully. I hope the editor will share the content of phpcms v9 to determine whether a user is logged in or not. At the same time, I also hope that you will support us, pay attention to the industry information channel, and find out if you encounter problems. Detailed solutions are waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report