Skip to content
Advertisement

IP.Board – Single Sign On in php

I’m developing a small hand made web portal for a community and I want it to have a loggin system with IP.Board (easier for the end user).

I have the forum and the app on the same hosting. For the loggin, the user clicks on a button and is redirected to this page:

<?php
require_once '../www/forum/init.php';
include_once 'includes/functions.php';
error_reporting(E_ALL);
session_start();
    IPSSessionFront::i(); 
    print_r( IPSMember::loggedIn());
    if(IPSMember::loggedIn()->member_id) {
        $name = IPSMember::loggedIn()->name;
        if(checkUserExistance($name)==0){                       
            //header("Location: ../index.php"); 
            print("LOGED EXIT!!!!!!!!!!!!!!!!!!!!");
        }else{
            print("LOGED INNNN!!!!!!!!!!!!!!!!!!!!");
            $_SESSION['authenticated'] = 'yes';
            $_SESSION['user'] = $name;
            $userphoto = IPSMember::loggedIn()->photo;            
            $result = getUserData($_SESSION['user']);
            $_SESSION['isLeader'] = $result['isLeader'];
            $_SESSION['isAdmin'] = $result['isAdmin'];
        }           
    } else{
        print("LOGED OUT!!!!!!!!!!!!!!!!!!!!");
        $_SESSION['authenticated'] = 'no';
        if(session_destroy()){ // Destroying All Sessions   
            //header("Location: index.php");
        }
    }
    //echo "Auth by LOGIN";

?>

If is not logged in IP.Board session (forum), it goes back to index.php

For now im developing a basic version of it, more improvements will be done once I get this working.

As you can see I have a print for debuging some data. On Edge everything works, but on Firefox or chrome I get a string of 32 characters, each time a diferent one, instead of getting the username. Example of what i get in Firefox and Chrome.

ef5cd2de05387b9b01048efad2173efd

Does any one know why is this?

INFO: I followed: IP.Board SSO Documentation

INFO2: Forum post

I’m using IPS Community Suite as the “Master”.


EDIT 1: Debug of IPSMember::loggedIn()

IPSMember Object ( [nodeClass:protected] => IPSawardsCats [_followData] => [_previousPhotoType:protected] => [_group] => [restrictions:protected] => [modPermissions:protected] => [calculatedLanguageId:protected] => [markers] => Array ( ) [markersResetTimes:protected] => Array ( ) [haveAllMarkers:protected] => [defaultStreamId:protected] => [changedCustomFields] => Array ( ) [previousName:protected] => [_socialGroups:protected] => [sessionData:protected] => [_lang:protected] => [_url:protected] => [profileFields] => [_reputationData:protected] => [_following:protected] => Array ( ) [reportCount:protected] => [ignorePreferences:protected] => [_ppdLimit:protected] => [_data:protected] => Array ( [member_group_id] => 2 [mgroup_others] => [joined] => 1483440989 [ip_address] => 83.36.150.111 [timezone] => UTC [allow_admin_mails] => 1 [pp_photo_type] => [member_posts] => 0 [pp_main_photo] => [pp_thumb_photo] => [failed_logins] => [pp_reputation_points] => 0 [signature] => [auto_track] => {“content”:0,”comments”:0,”method”:”immediate”} ) [_new:protected] => 1 [changed] => Array ( [member_group_id] => 2 [mgroup_others] => [joined] => 1483440989 [ip_address] => 83.36.150.111 [timezone] => UTC [allow_admin_mails] => 1 [pp_photo_type] => [member_posts] => 0 ) [skipCloneDuplication] => )

Advertisement

Answer

I decided to use the other option for SSO in IP.Board Te other option, sends the login request to the forum, and does not need to check the sessions. Forum API does it.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement