ThinkPHP5 development (3) code sharing using Behavior to detect user logon status

Source: Internet
Author: User
In the tags. php Directory of the application directory (a new one is created without a fixed name and cannot be changed), the behavior is bound to a tag. here it is bound to "CheckAuth"

Directory structure:

1. create UserCheck. php under the user \ behavior Directory (the name can be used as needed)

 Error ('log on! ', 'Index/login ');}}

Here, the run function adds the logic for checking user permissions. you can use session or other...
2. in the tags. php directory under the application directory (if no one is created, the name cannot be changed), bind the behavior to a tag. here, it is bound to "CheckAuth"

  [        'app\\user\\behavior\\UserCheck',    ],];

3. write the listening tag code where the controller needs to listen
User \ controller \ Index. php

 

The above is the code shared by ThinkPHP5 development (3) using Behavior to detect user logon status. For more information, see other related articles in the first PHP community!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.