• I am curently using WP_Session manager to manage global variables that I want to share between pages.
    I can set, pass and view WP_session variables between my standard wordpress pages.
    However I have a requirement to post data to a php file I created called checkout_manager.php.

    When I attempt to retrieve the session data using the code below, nothing is being retrieved.

    Any help would be greatly appreciated.

    $cart=array();
    if (isset($wp_session))
    {
    if (isset($wp_session[‘cart’]))
    {
    $cart=$wp_session[‘cart’]->toArray();
    $count=count($cart);
    }
    }

    http://wordpress.org/extend/plugins/wp-session-manager/

Viewing 1 replies (of 1 total)
  • Hi! The FAQ short info isn’t for all levels of understanding.
    I am using it like this from a plugin or functions.php:

    function location_session () {
     global $wp_session;
     $wp_session = WP_Session::get_instance();
    }
    add_action( 'init', 'location_session' );

    and in the header.php i use it like this to set a variable for test:

    <?php
    global $wp_session;
    $wp_session['location'] = "mycity";
    ?>

    After loading the page and assuming the variable is set, I replace the previous 2 lines with this to echo the variable as a test:

    <?php
    global $wp_session;
    echo $wp_session['location'];
    ?>

Viewing 1 replies (of 1 total)
  • The topic ‘WP_Session variables are being lost’ is closed to new replies.