ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

User auto-login (SSO) and start_session issue

October 04, 2013 7:07am

Subscribe [1]
  • #1 / Oct 04, 2013 7:07am

    Feendish

    1 posts

    Hi all,

    I’ve a client who wants us to integrate their own SSO module with EE so any of their users who goes to the EE site once they get past their SSO login page will be automatically logged in.

    From what I’ve seen so far the start_session code in Auth library is what I need. I got it going by hooking onto the login hook.

    What I need though is for it to be called on every page reload so I tried hooking into the sessions_start and sessions_end.

    The following code is what I had in my hook function. Note for testing I’m using a cookie.

    $this->EE =& get_instance();
    
    $user_info_username = $_COOKIE["username"];
    
    $this->EE->db->where('username', $user_info_username);
    
    $member = $this->EE->db->get('members');
        
    $loaded_user = $member->row();
        
    if (empty($loaded_user)){
      $this->invalidUser();
     exit;     
    }
        
    $this->EE->load->library('auth');
        
    // Load a new Auth_result object which logs in the member
    $authed = new Auth_result($member->row());
        
    $authed->start_session($cp_session = FALSE);
    
    $member->free_result();
       
       
    return true;

    Problem I have is I’m getting an error:

    A PHP Error was encountered

    Severity: Notice

    Message: Undefined property: EE::$session

    Filename: libraries/Auth.php

    Line Number: 757

    where the Auth library tries to do start_session.

    Can anyone suggest a solution?

    I’ve been mulling over just adding a php header redirect to the top of my template which will go to a php enabled template to run the above code if the user is logged out and SSO integration is enabled.

    Problem there is two fold: not sure it’ll work and it seems very clunky.

    Thanks.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases