• Hi guyz,

    I have some issue with the wordpress Sessions.. I used the standard PHP $_SESSION[‘cart’][] = value to add an item to a session array. this works fine with plain php file but when i use the same file and code within the wordpress plugin its no longer working..

    the output always shows 1 item even though i already added more items in the cart using this.. i also used the php array_push to insert an item but still no luck..

    can somebody tell me how to solved this, i will be glad if there are people who can help me with this… peace and thanks in advance..

Viewing 2 replies - 1 through 2 (of 2 total)
  • Did you session_start() your session? – I would always forget and $_SESSION wouldn’t work as expected.

    In your plugin or theme’s functions.php:

    function register_my_session() {
      if( !session_id() )
        session_start();
    }
    add_action('init', 'register_my_session');
    Thread Starter ginteno

    (@ginteno)

    Hi,

    Yes i already did that. the session works fine.. but the session array is not working.. every time i add new index or item in the session array variable the session variable only shows array(0=>”item 1″) it’s supposed to be adding a new item or index but instead it wont. i use the same script using plain php and it works perfect but when i use the same script within a php file inside the plugin directory, then it starts to no longer work any more. by the way i use this session variable to add cart items $_SESSION[‘cart’][] = “New Index”; //Works fine with plain PHP

    can you help me solve this??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding Item to PHP $_SESSION['cart'][] = value not WORKING..’ is closed to new replies.