Uutiset:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu
Advertisement:

Losing session variable in forums

Aloittaja Staggan, toukokuu 15, 2014, 09:52:19 AP

« edellinen - seuraava »

Staggan

Hello

We are using the smf 2 api to integrate SMF into our site, which is working well, but we have a problem with a session variable.

Once we have successfully logged a user in we set the following session var:



$_SESSION["loggedIn"] = 1;



And use that to decide if we show the user as logged in or not.

This works fine on every single page except the forums page. Our header / menu loads fine but it seems that the session variable is somehow lost. However, if we go back to the site home page, our session variable is still working as it shows us still logged in.

Any ideas? Does the forum do something to prevent or reset my session variable?

Any help would be greatly appreciated

Thanks


Staggan

I have tried not starting a new session by doing this in /forums/Sources/load.php



if(session_status() === PHP_SESSION_NONE) {
session_start();
}



But it makes no difference..


margarett

I'm not sure how the API works, but with SSI you can just use $context['is_logged'] which is set by SMF upon successful login. I assume something similar exists with the API.

Or aren't you using SMF's login system?
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

LainaaOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Staggan

Hello

No, we have our own login system.

We were using PHPBB, but changed.... just having a few issues...


Arantor

Of course it will be lost. SMF has its own session handler. On the downside, this means it's usually far easier to not roll your own and extend SMF's, but on the upside you get something that's been around for a decade and proven against things like session fixation bugs which seem to crop up in NIH environments.

This is why I said to you before about doing it SMF's way.
Holder of controversial views, all of which my own.


Staggan

Our login system is based around our online game, and has been around quite some time, and therefore we need SMF to integrate into our system in the same way PHPBB did....

I can register users and log users in without issue, all good, but when it comes to logging users out and setting the logged in status at the top of the header page, it is a pain.

I'll spend a little more time looking at it..


Thanks


Advertisement: