1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Session and cart

Discussion in 'XenForo Development Discussions' started by Mythotical, Aug 1, 2012.

  1. Mythotical

    Mythotical Well-Known Member

    I'm not so good with session stuff so if anyone can give me some advice for using session to have a cart then adding items to that cart without inserting to a table in the database.

    So far I have this:

        public function actionCart()
    $cart_cached XenForo_Model::create('XenForo_Model_DataRegistry')->get('cart');
    $item $this->_input->filterSingle('item_id'XenForo_Input::STRING);
    $session XenForo_Session::startPublicSession();

    $cart $cart_cached;
            if (!
    $cart) {
    $cartMessage 'You have no items in your shopping cart.';
            } else {
    $items explode(',',$cart);
    $s = (count($items) > 1) ? 's':'';
    $cartMessage 'You have <a href="cart.php">'.count($items).' item'.$s.' in your shopping cart</a>';

    $viewParams = array(
    'onlineUsers' => $this->_getSessionActivityList(),
    'cartMessage' => $cartMessage

    Thanks in advance
  2. Arty

    Arty Well-Known Member

    Check out $session->set, $session->get and $session->isRegistered in library/XenForo/Session.php
  3. Mythotical

    Mythotical Well-Known Member

    Thanks Arty

Share This Page