嗨朋友我在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
}
}
以上代码对我有用但不在server.you注意到我自动加载会话库
答案 0 :(得分:7)
尝试一些替代方案可能有效:
在application/config/config.php:
$config['sess_cookie_name'] = 'cisession'; //remove(underscore)
$config['cookie_domain'] = ".example.com"; //make it site wide valid