Jump to content

Big problem with external website session


Subzero-mb

Recommended Posts

I am having a big problem when I supposed I had everything ready to start with IPS4...

I had an external website integrated with IPS3 forum, and now with IPS4. Forum is installed inside a folder (mydomain.com/forum). The integration is pretty easy, in the index of my external website I have something like that:

<?php

/* Require the init.php file from the Community Suite root directory */
require 'forum/init.php';

/* Initiate the session to verify who this user is */
\IPS\Session\Front::i();

/* Get user data  */
$user = \IPS\Member::loggedIn();

/* Check if user is logged in or not */
if ($user->member_id)
  echo "User is logged in";
else
  echo "User is a guest";
?>

 

 

As usual, if I enter in the forum index after 1 hour, 2 days, whatever, I see I continue log in with my username. But if instead of enter directly in mydomain.com/forum I enter in the index of my website (mydomain.com) I am not logged in, I appear as a guest. If I go to the forum, I move a little bit between subforums, topics or profiles, then I returned to the index of my external website and now I appear like logged in member.

I have noticed that this problem only happen if the script is outside of forum folder, if we create a file test.php with the previous code inside "/forum" folder and another file test.php in the root of my domain, we can see if we call file mydomain.com/test.php (after 5 or 10 minutes without visit the forum) the browser will show "User is a guest" but if then we visit mydomain.com/forum/test.php we will see "User is logged in". Then if you navigate a little bit inside your forum and you return to mydomain.com/test.php now you will se "User is logged in".

It looks like you need to "reanimate" the session moving around your forum if you want that your external site shows you have an open session in this computer when you enter after some time outside of your forum. But as I said, if the test file is inside the forum directory this problem never happen.

Any idea about how to solve this? I am getting crazy trying to solve it. In IPS3 I had never had this problem. Thank you.

Link to comment
Share on other sites

Nobody has tried to connect an IPS4 forum with a custom website? I do not understand why it is not working properly in IPS4, I am just doing what is written in the official documentation: http://community.invisionpower.com/4docs/advanced-usage/development/single-sign-on-sso-r98/   "Reading the Community Suite session" but if the code is in a file outside of forum folder is not working properly.

/* Require the init.php file from the Community Suite root directory */
require '/path/to/suite/init.php';

/* Initiate the session to verify who this user is */
\IPS\Session\Front::i();

/* Print the user's name */
print \IPS\Member::loggedIn()->name;

Anyone can help me please? If I put this code in a file inside of forum folder everything works fine and I always get the user name. But if I put this code outside of forum folder (in my domain root directoy) I get many times a guest name insted of the user name who is logged in.

Link to comment
Share on other sites

(w00t)(w00t)(w00t) thank you so much @Ahmad El-Oukly!!! I have tried right now and it works. I have been all day looking how to fix it and it was so easy in the end. Thank you, you are great.

 

I even opened a support ticket, I am going to close it but I will sugest IPS to update the guide with this information for people like me who save the forum in a different folder.

Link to comment
Share on other sites

Archived

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Upcoming Events

    No upcoming events found
×
×
  • Create New...