codeigniter session working on local host but not working on server and also sit

隐身守侯 提交于 2020-01-01 14:53:10

问题


Hi Friends I am struggling session in codeigniter everything working fine my system but server or sit machine not working session

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
        }
    }

the above code is working to me but not working on server.you notice this i am auto load the session library


回答1:


Try a few alternatives may work:
Change these lines in application/config/config.php:

$config['sess_cookie_name'] = 'cisession';     //remove(underscore)
$config['cookie_domain']    = ".example.com";  //make it site wide valid


来源:https://stackoverflow.com/questions/19024597/codeigniter-session-working-on-local-host-but-not-working-on-server-and-also-sit

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!