Customer Portal

Get Involved. Join the Conversation.

Topic

    ebingham
    PTA - External Logout with /ci/ajaxRequest/dologoutAnswered
    Topic posted February 18, 2009 by ebingham Blue Ribbon: 750+ Points, last edited October 29, 2011 
    2191 Views, 12 Comments
    Title:
    PTA - External Logout with /ci/ajaxRequest/dologout
    Content:

    We are currently setting up the PTA. I was looking at some of the other posts about External Logout and in one of them it said to use /ci/ajaxRequest/dologout as the url.  When I use that url I recieve this message. {"url":"0","session":"","success":1}  I was wondering if there were additional steps that I needed to take so that it would then redirect the customer back to the home page.

    Best Comment

    Ernie Turner

    Thats just a minor problem with how the ajaxCustom class is coded out. At the top of that file, your class should be defined as so

     

     

    class ajaxCustom extends ControllerBase { function __construct() { parent::__construct(); } function performLogout() { ....

     

     

    Comment

     

    • Ernie Turner

      I'm assuming you're talking about the two comments starting here. The suggestion there was to create a new function in the ajaxCustom controller which then calls contact_model. I think thats a better solution than your method of calling /ci/ajaxRequest/doLogout directly. This way you have control after the logout to redirect the user back to where you want.

       

      Note: This is basically pseudocode, I didn't actually try this 

      function performLogout()
      {
      $this->load->model('standard/Contact_model');
      $result = $this->Contact_model->doLogout($url);
      if($result['success'])
      header('Location: /app/home');
      }

       

    • ebingham

      ok I at first didn't see where the file was do to this at first but I found it at development/controllers/ajaxCustom.php.  I added the code that you listed below which you said may not work which didn't exactly.  The line below is what is failing for me.


      $result = $this->Contact_model->doLogout($url);

        I'm not really sure what needs to go un the $url.  I saw some other code so I tried both of the following pieces of code.


      $this->CI->contact_model->doLogout('/app/utils/login_form');
      $this->Contact_model->doLogout('/app/utils/login_form');

      but neither of these brought sucessful results and I received the following error message

       

      Fatal error: Call to a member function doLogout() on a non-object in /cgi-bin/underarmour.cfg/scripts/euf/application/development/source/controllers/ajaxCustom.php on line 27

    • Ernie Turner
      It seems like maybe your ajaxCustom controller is coded wrong if you are getting that error. Can you attach the file so I can see what it contains? Also, you don't really have to pass anything in for the $url parm, you can just pass in a blank string, $result = $this->Contact_model->doLogout('');. That parameter is more used when performing this logic during an Ajax request.
    • ebingham

      Here is my file and let me know know if I'm missing anything.  It wouldn't let me send a php file so I zipped it.

    • Ernie Turner

      When loading the model, you have this

       

       

      $this->load->model('standard/contact_model');

       

      The contact_model part needs to be capitalized, so it looks like this (which is how I pasted it earlier)

       

       

      $this->load->model('standard/Contact_model');

       Give that a shot and it should work.

       

       

    • ebingham

      The code on the other thread about external logout had it lower case and I must have copied my code from there instead of this thread but I used the code below and I got the same error

      function performLogout() { $this->load->model('standard/Contact_model'); $result = $this->Contact_model->doLogout(''); if($result['success']) header('Location: /app/home'); }

       

      Error Message: 

      Fatal error: Call to undefined method contact_model::doLogout() in /cgi-bin/underarmour.cfg/scripts/euf/application/development/source/controllers/ajaxCustom.php on line 27

       

       

       

    • Ernie Turner

      Ah, sorry, this code will only work for November '08, and based on your other post you're running August '08. So, I guess you have two options a) Wait to implement this once you upgrade, or b) You could give this other code a shot

       

       

      function performLogout() { $sid = $this->session->getSessionData('sessionID'); custlogout_session($sid, $this->session->getProfileData('cookie')); $this->session->performLogout(); header("Location: /app/home"); }

       

       

       

    • ebingham

      gotcha that worked and I'll keep the other code ready for when we upgrade to a newer version. 

       

      On a side note it might be helpful to add a field somewhere so the person posting knows to put what version they are using it probably would have helped some of this back and forth.

    • ebingham

      We upgraded our version and I updated the ajax codde to

       

       

      function performLogout() { $this->load->model('standard/Contact_model'); $result = $this->Contact_model->doLogout(''); if($result['success']) header('Location: /app/home'); }

       

       and now I'm getting the following error:

       

      Controller classes must derive from the ControllerBase class. The '/cgi-bin/underarmour.cfg/scripts/euf/application/development/source/controllers/ajaxCustom.php' controller does not.

       

      Please let me know if you have any ideas on how to fix this.

      Thanks

       

    • Ernie Turner

      Thats just a minor problem with how the ajaxCustom class is coded out. At the top of that file, your class should be defined as so

       

       

      class ajaxCustom extends ControllerBase { function __construct() { parent::__construct(); } function performLogout() { ....

       

       

    • ebingham
      Thanks I didn't realize that got update in the upgrade.  Thanks
    • erich hannan

      It's worth noting that a number of PTA enhancements were added in the May '09 release including:

      1) A Logout page – located at /ci/pta/logout
      2) A new configuration setting called MYSEC_EXT_LOGOUT_URL

       

      You can just hit /ci/pta/logout and it will take care of all the cookie and session cleanup, and then redirect to the URL specified in MYSEC_EXT_LOGOUT_URL.  So, you can eventually remove this custom code.

       

      Anybody else following this thread should consider upgrading to May '09 to get the standard logout functionality.