Skip to:
Content

BuddyPress.org

Changeset 1503 for trunk/bp-core.php


Ignore:
Timestamp:
06/03/2009 10:49:34 PM (16 years ago)
Author:
apeatling
Message:

Removed the use of sessions in BuddyPress, as this is not a robust solution when installed on a multi-server setup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core.php

    r1482 r1503  
    11<?php
    2 
    32/* Define the current version number for checking if DB tables are up to date. */
    43define( 'BP_CORE_VERSION', '1.0' );
     
    171170add_action( 'plugins_loaded', 'bp_core_setup_root_components', 1 );
    172171
    173 function bp_core_setup_session() {
    174     // Start a session for error/success feedback on redirect and for signup functions.
    175     @session_start();
     172function bp_core_setup_cookies() {
     173    global $bp_message, $bp_message_type;
    176174   
    177175    // Render any error/success feedback on the template
    178     if ( $_SESSION['message'] != '' )
    179         add_action( 'template_notices', 'bp_core_render_notice' );
    180 }
    181 add_action( 'wp', 'bp_core_setup_session', 3 );
     176    if ( $_COOKIE['bp-message'] == '' || !isset( $_COOKIE['bp-message'] ) )
     177        return false;
     178
     179    $bp_message = $_COOKIE['bp-message'];
     180    $bp_message_type = $_COOKIE['bp-message-type'];
     181    add_action( 'template_notices', 'bp_core_render_notice' );
     182
     183    setcookie( 'bp-message', false, time() - 1000, COOKIEPATH );
     184    setcookie( 'bp-message-type', false, time() - 1000, COOKIEPATH );
     185}
     186add_action( 'wp', 'bp_core_setup_cookies', 3 );
    182187
    183188function bp_core_install() {
     
    847852    if ( !$type )
    848853        $type = 'success';
    849    
    850     $_SESSION['message'] = $message;
    851     $_SESSION['message_type'] = $type;
     854
     855    setcookie( 'bp-message', $message, time()+60*60*24, COOKIEPATH );
     856    setcookie( 'bp-message-type', $type, time()+60*60*24, COOKIEPATH );
    852857}
    853858
     
    862867 */
    863868function bp_core_render_notice() {
    864     if ( $_SESSION['message'] ) {
    865         $type = ( 'success' == $_SESSION['message_type'] ) ? 'updated' : 'error';
     869    if ( $_COOKIE['bp-message'] ) {
     870        $type = ( 'success' == $_COOKIE['bp-message-type'] ) ? 'updated' : 'error';
    866871    ?>
    867872        <div id="message" class="<?php echo $type; ?>">
    868             <p><?php echo $_SESSION['message']; ?></p>
     873            <p><?php echo $_COOKIE['bp-message']; ?></p>
    869874        </div>
    870     <?php
    871         unset( $_SESSION['message'] );
    872         unset( $_SESSION['message_type'] );
    873        
     875    <?php
    874876        do_action( 'bp_core_render_notice' );
    875877    }
Note: See TracChangeset for help on using the changeset viewer.