duanfenhui5511 2013-06-20 09:21
浏览 43
已采纳

codeigniter插入数据的购物车问题

i am new to code-igniter. here i am using shopping cart for product checkout. when i am add product to cart it's working for first three products, after adding any product consider as fourth product. if any product add to cart after three products it will replace the existing fourth product. but only first three product display on cart, and the fourth one not display and also i cant add more than four products on cart, i am using jquery ajax for cart update

jquery ajax code

$('.addcart').click(function(){
    var proid=$(this).attr('id');           
    $.post('<?php echo base_url()?>productajax',{typ:'addtocart',proid:proid},function(data){           

    })
    return false;
})

product add to cart code



 $proid=$this->input->post('proid');
                    $this->db->where('pro_id',$proid);
                    $data=$this->db->get('product')->result();
                    foreach ($data as $pro)
                    {
                        $proname=$pro->pro_name;
                        $price=$pro->s1price;

                        $proimg=$pro->image_name;
                        $nwt=$pro->case_netweight;
                        $gwt=$pro->case_grossweight;
                        $cbm=$pro->cbm;
                    }

                    $propriceinr =round($price + round(($price * $this->session->userdata('user_margin'))/100,2));          

                    $dat = array(
                   'id'      => $proid,
                   'qty'     => 1,
                   'price'   => $propriceinr,
                   'name'    => $proname,
                   'options' => array('cbm' => $cbm, 'nwt' => $nwt,'gwt'=>$gwt,'image' => $proimg ,'price'=>$price,)
                );              
                    $this->cart->insert($dat);

config.php

$config['sess_cookie_name']     = 'ci_session';
$config['sess_expiration']      = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie']  = FALSE;
$config['sess_use_database']    = FALSE;
$config['sess_table_name']      = 'ci_sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update']  = 300;

$config['csrf_protection'] = FALSE;
$config['csrf_token_name'] = 'csrf_test_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire'] = 7200;

i don't know the product cart why not update after insert three product. give me a guidance for this issue anyone. thanks advance

  • 写回答

2条回答 默认 最新

  • doukui4786 2013-06-20 12:09
    关注

    Please set

    $config['sess_use_database'] = FALSE;

    to $config['sess_use_database'] = TRUE; in your config.php.

    Right now your products details are being saved in cookie which has the maximum limit of 4kb.
    By enabling $config['sess_use_database'] = TRUE;.

    This feature lets you insert your information in database table i.e:

    $config['sess_table_name'] = 'ci_sessions';.

    Hope that will work for you

    If you dont have ci_sessions table here is the query for that:

     CREATE TABLE `ci_sessions` (
     `session_id` varchar(40) NOT NULL DEFAULT '0',
     `ip_address` varchar(16) NOT NULL DEFAULT '0',
     `user_agent` varchar(50) NOT NULL,
     `last_activity` int(10) unsigned NOT NULL DEFAULT '0',
    `user_data` text NOT NULL,
    PRIMARY KEY (`session_id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题