Problem with integrating SMF in a custom built website

Started by ChrisVSLT, June 25, 2012, 04:44:25 PM

Previous topic - Next topic

ChrisVSLT

Hi folks,

Thanks for reading this message and even more thanks for replying on it, if you would.

I am dealing with a problem that's getting a bit annoying by now as I can't find a solution for it. What I have is a custom built PHP site in my root folder with an SMF forum in a folder called /forum. Both have the same style so style technically, they are the same. Check out the screenshot before reading further.



When I login to the forum when I am logged out of there, I get logged in and ssi_welcome() which is displayed in the blue bar ('hoi, chris ..') says what it says when an user is logged in. When I then go back to my custom built site, it does the same.

There's no problem, isn't it? No, not really. After a certain amount of time (I don't know exactly how many minutes) it looks like the session has vanished because I then get the situation displayed above. When I go to my custom built site it says 'Welcome, guest, please login or register' and when I click on 'forum' to go to the forum, it actually does display 'hi, chris, you have 0 personal messages, 0 are new'. I somehow think the session has vanished (?) which makes it impossible to display on the custom built site. But then why does it show up on the forums?

What I have included through a require() on my custom built site is my own function to get the amounts of visitors online out of smf_log_online, a custom made 'function' to connect to the database and (the correct) path to SSI.php. I have searched the forums for any clues but I didn't find any. I am wondering if anyone knows how to fix this problem, and would really appreciate some help, or even a kick off with some tips.

Thanks a lot,
Chris

Arantor

Quotea custom made 'function' to connect to the database and (the correct) path to SSI.php.

Don't do that if at all possible.

Just include SSI, it will sort out its own database connection - including the session handler. In SMF, sessions are generally held in the database and as such you need to leave SMF alone to let it do its thing.

There is also a dedicated SSI function for getting the number of people in the online log, and it also bumps said log to make sure you're still showing as logged in, ssi_logOnline if I remember rightly.

ChrisVSLT

Thanks for your reply!

When I remove my own SQL function, I get SQL errors because I also run other queries on the site that have nothing to do with SMF.

I already had ssi_logOnline() in my code (sorry for not explaining in my first post) to count the number of people being online, however it does not work to show you as "logged in" when the script executes ssi_welcome().

Arantor

Could be related to cookies, check whether cookies are set to be subdomain independent or not in the Server Settings page.

But in any case you need to run SSI.php first, let it set up its cookies - you can if you need to set up your own database connection and queries (or reuse SMF's connection if the DB username/password are the same), but it must be done after SSI.php has been included.

ChrisVSLT

They were set as subdomain dependent so I disabled that option and logged in again.

Now it's all good, but that was the same as I stated in my first post. I'll have to and will wait for like an hour to see whether it keeps working or not.

I'll let you know!

Thanks for your answer :)

PS: I also did what you said about the SSI file

ChrisVSLT

Arantor, you are a hero! It looks like it's all fixed now.  8)

Advertisement: