Recent Topics

Logout event can't set cookies

Started by on Oct 01, 2007 – Contents updated: Oct 01, 2007

Oct 01, 2007 18:51    

Code

/**
   * Event handler: called when a user logs out.
   *
   * This is meant to cleanup data, e.g. if you use the
   * {@link Plugin::AlternateAuthentication()} hook.
   *
   * @see Plugin::AlternateAuthentication()
   * @see Plugin::Logout()
   * @param array Associative array of parameters
   *   - 'User': the user object
   */
  function Logout( $params )
  {
    
    // ----------------------------------------------------
    // Let's do some support for the Gallery Plugin
    
    setcookie('gallery__b2evo_user_shit', '', 1, '/');
    
    // ----------------------------------------------------
    
    return true;
  }

doesn't work

but this does

Code

/**
   * Event handler: called when a user logs out.
   *
   * This is meant to cleanup data, e.g. if you use the
   * {@link Plugin::AlternateAuthentication()} hook.
   *
   * @see Plugin::AlternateAuthentication()
   * @see Plugin::Logout()
   * @param array Associative array of parameters
   *   - 'User': the user object
   */
  function Logout( $params )
  {
    
    // ----------------------------------------------------
    // Let's do some support for the Gallery Plugin
    
    setcookie('gallery__b2evo_user_shit', '', 1, '/');
die;
    
    // ----------------------------------------------------
    
    return true;
  }

Oct 01, 2007 19:02

Solved by using

Code

/**
   * Event handler: Called at the end of the login procedure, if the
   *                user is anonymous ({@link $current_User current User} NOT set).
   *
   * Use this for example to read some cookie and define further handling of
   * this visitor or force them to login, by {@link Plugin::msg() adding a message}
   * of class "login_error", which will trigger the login screen.
   */
  function AfterLoginAnonymousUser( & $params )
  {
    // ----------------------------------------------------
    // Let's do some support for the Gallery Plugin
    
    setcookie('gallery__b2evo_user_shit', '', 1, '/');
    
    // ----------------------------------------------------
    
    return true;
  }

Oct 01, 2007 19:13

Cool, still weird it failed though, can you send me a link to a zip of your gallery plugin where it failed and I'll install 1.10.x and see what the problem is ?

¥

Oct 01, 2007 19:43

In the above solution I also had to change return true to just return; otherwise the login page would just keep popping up.

Yeah will do when I can.

Oct 01, 2007 19:46

balupton wrote:

In the above solution I also had to change return true to just return; otherwise the login page would just keep popping up.

Wonder if it'd fry the core if you returned false? gonna have to try :roll:

No rush, it's liable to be tomorrow before I get chance to play

¥

Oct 01, 2007 22:09

Actually, I just tested it then in a demo, and didn't even work... so seems to be more or less random, maybe i'm just crazy though...

Can you pm me your email or something so I can send you the the gallery plugin.

Oct 01, 2007 23:09

wherever_you_like @ my blog ;)

Although spam@innervisions won't work cos it keeps getting spammed :P

¥


Form is loading...

powered by b2evolution – This forum is powered by b2evolution CMS, a complete engine for your website.