Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Modding Central Posted August 26, 2015 Posted August 26, 2015 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.
Modding Central Posted August 31, 2015 Author Posted August 31, 2015 Apologise if not allowed to bump but still having issues with this.
TSP Posted September 1, 2015 Posted September 1, 2015 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.
Modding Central Posted September 3, 2015 Author Posted September 3, 2015 Perfect, that seems to have fixed the issue.Many Thanks
Shariq Ansari Posted September 3, 2015 Posted September 3, 2015 Shouldn't cookie path be a configurable setting in the ACP? I feel like it was, before...
Modding Central Posted September 16, 2015 Author Posted September 16, 2015 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.
Modding Central Posted September 17, 2015 Author Posted September 17, 2015 I still need help with this Is it best to open a support ticket in my customer profile instead of asking here?
Recommended Posts
Archived
This topic is now archived and is closed to further replies.