Ticket #26: fix-cookie-domain-dont-delete-cookies.diff

File fix-cookie-domain-dont-delete-cookies.diff, 1.9 KB (added by westi, 2 years ago)

Improved fix

  • gp-settings.php

     
    226226// So, make all local variables, global 
    227227gp_set_globals( get_defined_vars() ); 
    228228 
     229/** 
     230 * It is possible to define this in wp-config.php and it will be used as the domain for all cookies. 
     231 * Set it carefully for sharing cookies amonst subdomains 
     232 *  
     233 * @link http://curl.haxx.se/rfc/cookie_spec.html 
     234 */ 
     235if ( !defined('GP_COOKIE_DOMAIN') ) 
     236        define('GP_COOKIE_DOMAIN', false); 
     237 
    229238if ( !class_exists( 'WP_Auth' ) ) { 
    230239        require_once( BACKPRESS_PATH . 'class.wp-auth.php' ); 
    231240        $cookies = array(); 
    232241        $cookies['auth'][] = array( 
    233                 'domain' => isset($_SERVER['HTTP_HOST'])? $_SERVER['HTTP_HOST'] : '' , 
     242                'domain' => GP_COOKIE_DOMAIN, 
    234243                'path' => gp_url_path(), 
    235244                'name' => gp_const_get( 'GP_AUTH_COOKIE', 'glotpress_auth' ), 
    236245        ); 
    237246        $cookies['secure_auth'][] = array( 
    238                 'domain' => isset($_SERVER['HTTP_HOST'])? $_SERVER['HTTP_HOST'] : '' , 
     247                'domain' => GP_COOKIE_DOMAIN, 
    239248                'path' => gp_url_path(), 
    240249                'name' => gp_const_get( 'GP_SECURE_AUTH_COOKIE', 'glotpress_sec_auth' ), 
    241250                'secure' => 'true', 
    242251        ); 
    243252 
    244253        $cookies['logged_in'][] = array( 
    245                 'domain' => isset($_SERVER['HTTP_HOST'])? $_SERVER['HTTP_HOST'] : '' , 
     254                'domain' => GP_COOKIE_DOMAIN, 
    246255                'path' => gp_url_path(), 
    247256                'name' => gp_const_get( 'GP_LOGGED_IN_COOKIE', 'glotpress_logged_in' ), 
    248257        ); 
  • gp-includes/misc.php

     
    8282        foreach ($_COOKIE as $key => $value ) { 
    8383                if ( gp_startswith( $key, $prefix ) && $suffix = substr( $key, strlen( $prefix ) )) { 
    8484                        GP::$redirect_notices[$suffix] = $value; 
     85                        setcookie( $key, '', 0, gp_url_path() ); 
    8586                } 
    86                 setcookie( $key, '', 0, gp_url_path() ); 
    8787        } 
    8888} 
    8989