Jump to content

Custom Web Application Integration Issues


Modding Central

Recommended Posts

Posted

Hello I hope I have placed this in the correct area,

I'm trying to get the information on the logged in user of the IPB forum via my custom web application, but it always return a guest user.

My application is part of the same website the forum is on. Here's the file structure to illustrate : 

- Website
    - forum (IPB install)
    - mods (my custom section)

Here's what I use to get the details of the current IPB user :    

 require_once "../forum/init.php";    

\IPS\Session\Front::i();        
$IPB_user = \IPS\Member::loggedIn();


The code above is working from time to time, but not all the time. It's not reliable and it's slow, there's a long delay between the moment the user physically logs in via the forum, and the moment the code above reflects it by providing the user details. Most of the time it will just send me the information about a guest user.

I've also found that sometimes it will work immediatly after doing an action on the forum, such as logging on the AdminCP and going on a sub-section in there. It's still not always working, and not convenient at all if the user has to do an action on the forum before my custom section can tell that he logged in.

What am I doing wrong? Is the code above the right code to get the details on the logged in user? Do I have to enable something in the adminCP of the forum for it work properly? 

Thanks for the help.

Posted

This is most likely because by default the cookie path is set so that you only have access to the IPS 4 cookies "beneath" the path where your community software is installed. They are not accessible on the entire domain. 

If you create (if it doesn't already exist) constants.php, in the root forum folder of your community, where init.php exists, and add this:

<?php
define('COOKIE_PATH', '/');

Do not add <?php or remove any existing entries if constants.php already exists.

Then I believe that should resolve the situation for you. But you may have to log out and in once more before it takes effect. 

  • 2 weeks later...
Posted
On 9/1/2015, 2:08:27, TSP said:

This is most likely because by default the cookie path is set so that you only have access to the IPS 4 cookies "beneath" the path where your community software is installed. They are not accessible on the entire domain. 

If you create (if it doesn't already exist) constants.php, in the root forum folder of your community, where init.php exists, and add this:


<?php
define('COOKIE_PATH', '/');

Do not add <?php or remove any existing entries if constants.php already exists.

Then I believe that should resolve the situation for you. But you may have to log out and in once more before it takes effect. 

Hi again,

I've created the constants.php file, added the proper code and it worked, for a little while.

Now it will only work for me. Nothing changed in our code, I didn't touch it in weeks. Other testers, using both Firefox and Chrome, don't show up as logged in on the custom section. However, it does work for them if they are trying it in Internet Explorer - which is not their default browser.

They tried clearing their cache and cookies, and they also had the issue in ingognito mode in Chrome.

Could it be a caching issue or something like that? Do I/they have to clear or reset anything? We've also tried restarting the server, that had no effect.

Thanks for the help.

 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...