Magento在超时前设置新会话

I am trying to add product to cart in magento, so i am checking the Session checkout cart items, When i am adding the products are adding to cart and session also has the cart item.

When I am trying continuously, sometimes my session has empty cart, so i checked the session id by logging PHP's session_id() function.

When I receive my cart is empty even my cart had items, so i checked the log,so this time the session_id() logs new_value even my session is not timed out.

How can i resolve this problem? My Code:

$cart = Mage::getModel('checkout/cart');
$product = Mage::getModel('catalog/product')
            ->setStoreId(Mage::app()->getStore()->getId())
            ->load($productId);
$cart->addProduct($product, $params);
$cart->save();
$this->_getSession()->setCartWasUpdated(true);