• Resolved itailulu

    (@itailulu)


    I’m trying to pass an array in $wp_session but I can’t retrieve it.
    This is what I did, on page 1:

    $wp_session = WP_Session::get_instance();
    $wp_session['user_contact'] = array( 'email' => 'user@name.com' );

    Then on page 2 i tried few things:

    $data = wp_session_encode();
    print_r($data);

    and got this:
    {“user_contact”:{}}

    print_r($wp_session);

    What am i doing wrong?

    Thanks!

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter itailulu

    (@itailulu)

    I think I got it.
    had to add:

    $session = WP_Session::get_instance();
    echo '<pre>';
    $data = $session->toArray();
    print_r($data);
    echo '</pre>';

    on page 2.

    Cool.
    Thanks for the plugin, very useful!

    Got a solution.Updating here,may be it will help someone oneday. :

    if(isset($_POST['id']))
    		{
    		echo "<h2 id='bookingResult' > You are successfully added to your Cart </h2>"."ID=".$_POST['id'];
    		$wp_session = WP_Session::get_instance();
    
    			if(isset($wp_session['ym_cart']) && !empty($wp_session['ym_cart']))
    						{
    						$temp_array = $wp_session['ym_cart']->toArray();
    						array_push($temp_array,$_POST['id']);
    						$wp_session['ym_cart']=$temp_array;
    						}
    					else
    						{
    						$wp_session['ym_cart']= array();
    						$wp_session['ym_cart'][]=$_POST['id'];
    						}
    
    	//	print_r($wp_session['ym_cart']);
    		echo '<pre>';
    $data = $wp_session['ym_cart']->toArray();
    print_r($data);
    echo '</pre>';
    
    	    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Can't pass an array’ is closed to new replies.