3

嗨朋友们,我在 codeigniter 中苦苦挣扎,我的系统一切正常,但服务器或坐机无法正常工作

public function voting() {    //like and dislike controller 

        $deal_id = $this->input->post('voteId');
        $upOrDown = $this->input->post('upOrDown');
        $session_id = $this->input->post('session_id');
       $voted_id = $this->session->userdata('voted');
        $voted_deal =$this->session->userdata('voted_deal');

        if ($voted_id == $session_id && $voted_deal == $deal_id) 
        { //defult session id voted id equla return 2

            echo 2; // it important for already voted or not checking purpose
        }
        else 
        {

            $status = "false";
            $updateRecords = 0;

            if ($upOrDown == 'upvote')
            { //like vote

                $updateRecords = $this->consumer_model->updateUpVote($deal_id);
            } 
            else 
           { //dis like vote

            $updateRecords = $this->consumer_model->updateDownVote($deal_id);
          }
          if ($updateRecords > 0) 
          { //updaterecords greaterthan zero return true and set the defult session id

             $this->session->set_userdata('voted_deal',$deal_id);
              $voted_deal=$deal_id;
              $voted_id = $session_id;
             $this->session->set_userdata('voted', $voted_id);
              $status = 1; 
          }

          echo $status;  // return status it important for voted sucessfully message
        }
    }

上面的代码对我有用,但在服务器上不起作用。你注意到我正在自动加载会话库

4

1 回答 1

7

尝试一些替代方案可能会起作用:
将这些行更改为application/config/config.php:

$config['sess_cookie_name'] = 'cisession';     //remove(underscore)
$config['cookie_domain']    = ".example.com";  //make it site wide valid
于 2013-09-26T09:41:25.480 回答