Heim >Backend-Entwicklung >PHP-Tutorial >ecshop提交订单时提示“您的购物车中没有商品”——解决方案_PHP教程
<span <span 1</span> <span /*</span><span * </span><span 2</span> <span * 检查cookie </span><span 3</span> <span * </span><span 4</span> <span * @access public </span><span 5</span> <span * @param </span><span 6</span> <span * </span><span 7</span> <span * @return void </span><span 8</span> <span */</span> <span 9</span> <span function</span><span check_cookie () </span><span 10</span> <span { </span><span 11</span> <span if</span> ( <span isset</span>(<span $_COOKIE</span>['ECS']) && <span isset</span>(<span $_COOKIE</span>['ECS']['user_id']) && <span isset</span>(<span $_COOKIE</span>['ECS']['password'<span ])) </span><span 12</span> <span { </span><span 13</span> <span $ecs_user_id</span> = <span $_COOKIE</span>['ECS']['user_id'<span ]; </span><span 14</span> <span $ecs_user_pass</span> = <span $_COOKIE</span>['ECS']['password'<span ]; </span><span 15</span> <span $sql</span> = "SELECT " . <span $this</span>->field_name ." AS user_name". <span 16</span> " FROM " . <span $this</span>->table(<span $this</span>->user_table) . <span 17</span> " WHERE ".<span $this</span>->field_id." = '<span $ecs_user_id</span>' AND ".<span $this</span>->field_pass." = '<span $ecs_user_pass</span>'"<span ; </span><span 18</span> <span $username</span> = <span $this</span>->db->getOne(<span $sql</span><span ); </span><span 19</span> <span if</span> (<span $username</span> && (<span $this</span>->charset != 'UTF8'<span )) </span><span 20</span> <span { </span><span 21</span> <span $username</span> = ecs_iconv(<span $this</span>->charset, 'UTF8', <span $username</span><span ); </span><span 22</span> <span } </span><span 23</span> <span return</span> <span $username</span><span ; </span><span 24</span> <span } </span><span 25</span> <span else</span> <span 26</span> <span { </span><span 27</span> <span return</span> ''<span ; </span><span 28</span> <span } </span><span 29</span> }</span>