I’m trying to create a site with Yii which need to have a forum and i choose phpBB3.
I spent the last 2 days looking for a solution in order to use the same login and password for both, now i’m able to login from Yii with the user and password from the forum but i’m stucked here.
Now the question is, how i can share the same cookie from Yii to phpBB3 and viceversa?
I read some thread where was suggested to work with cookie and session value of Yii but i don’t know how i can handle it, could please someone walk me through it?
You’re going to need to look at how phpbb3 authenticates users and then migrate that code over to Yii. It should be fairly straightforward provided both the forum and your Yii application are hosted on the same domain.
Though, you do present an interesting dilemma - your Yii powered application now relies on phpbb3 methodology to authenticate and manage users, which I personally have a bit of an issue with I dislike the idea of modelling your website’s code and functionality around a piece of 3rd party software, particularly if it’s only a small extension of the site. I analysed possible solutions a couple of months ago, and decided to just write my ow in Yii - http://mixxi.com/forum (still WIP).
I understand your dilemma but i’m forced to use phpBB3…
I thing i understand how i can handle this, phpBB3 store a cookie called “cookie-name”_sid which contain a string of character that is the session id, this string is also stored under the table `phpbb_sessions’.
I can read and modify this table, so my idea is the follow:
On site load check if there is an identity with the same sid stored inside the cookie (if present) under the table `phpbb_sessions’, if yes user_id is identified.
If there’s no sid stored you need to login, so on login create a sid with the assocated user_id inside table `phpbb_sessions’ and also create a cookie.
I know this could be a forced solution but is the best i have found
I’m currently implementing phpBB and Yii together. I’m building a site which will use the forum part (phpBB) as the login handling, so I’ll only check for that cookie. I’ll post a code example (or perhaps extension) for this later.
If you can live with having phpBB handling the login/logout part, you don’t have to write your own cookies from Yii. That way, it’s almost solved already!
as Yii has its own $config variable, its better to assign phpbbs $config to something else before Yii overwrites it. (it comes very handy if you use the api).
in the controller:
<?php
public function actionTest(){
global $user;
print_r($user->data);// will give you all the data associated with the logged in user or ANNONYMUS
}
?>
Here’s what [color="#FF0000"]$user->data[/color] array contains:
Use the options as for your needs. (I am not fan of this global keyword but it is a easier solution)
I am only stucked in login part. The auth class in phpbb handles the main login procedure but it creates errors on including fils. I am a bit new to yii. How yii inclues files with what reference? Controller? Yiibase? I tried to use absolute path but even then it fails. If someone can point some direction on this, my own login is done.
Hello guys, sorry if i’m not really present but i was a bit busy…
Anyway, i try your solution Itachi, if i understood correctly when i login from the forum i should get the user data inside [color="#FF0000"]$user->data[/color] varibale but i always get the user anonymous data not the user i logged in.