Integrate sessions of phpbb3

Source: Internet
Author: User
Tags php define
In many cases, we need to create a forum for the website. Of course, we cannot write a complete Forum from the beginning. In this case, the more economical approach is to adopt an open Source code Forum Program And then do a good job of Single Sign-On transformation.
The phpBB Forum program can be easily integrated with your website. The official website provides the sessions integration of phpbb3 and the sessions integration model of phpbb2. Article . Because the official website has stopped the maintenance of phpbb2, we will briefly introduce the bridging method of phpbb3 sessions.
First, set the following section Code Add to the page where you want to bridge phpbb3:
<? PHP define ('in _ phpbb', true); $ phpbb_root_path = (defined ('phpbb _ root_path '))? Phpbb_root_path :'. /'; $ phpex = substr (strrchr (_ file __,'. '), 1); Include ($ phpbb_root_path. 'Common. '. $ phpex );
// Start session management $ user-> session_begin (); $ auth-> ACL ($ user-> data); $ user-> setup ();?>

Note that the $ phpbb_root_path variable defines the relative path between your phpbb3 and your current file. You need to modify it according to your actual situation. For example, my phpbb3 is installed in the Forum directory, and I should replace it with the following code:
$ Phpbb_root_path = (defined ('phpbb _ root_path '))? Phpbb_root_path: './FORUM /';

Do not forget the last "/" directory character. Otherwise, the following code will go wrong.
The next step is to determine whether a user has logged on. If yes, the welcome message is output. If no, the login message is displayed.
<? PHP if ($ user-> data ['user _ id'] = anonymous) {echo 'Please login! ';}
Else {echo 'Thanks for logging in, '. $ user-> data ['username _ clean'];} [...]

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.