【问题标题】:localhost refused to connect on xampp issuelocalhost 拒绝在 xampp 问题上连接
【发布时间】:2020-02-22 07:19:01
【问题描述】:

我尝试在 Codeigniter php 上创建一个会话示例,这是我的 Sesion_controller.php 代码。

class Session_controller extends CI_Controller {

  public function index() { 
      //loading session library 
      $this->load->library('session');

      //adding data to session 
      $this->session->set_userdata('name','ABC');

      $this->load->view('session_view'); 
  } 

  public function unset_session_data() { 
      //loading session library
      $this->load->library('session');

      //removing session data 
      $this->session->unset_userdata('name'); 
      $this->load->view('session_view'); 
  }         
}

这是我的 Session-view.php 代码

<body> 
  Welcome <?php echo $this->session->userdata('name'); ?>
  <br> 
  <a href = 'http://localhost:8081/codeigniterPhp/index.php/sessionex/unset'>
      Click Here</a> to unset session data. 
</body>

根据我在 routes.php 文件中所做的更改

$route['sessionex'] = 'Session_Controller';

在我的本地服务器上运行此代码后,视图页面正常运行,但我在控制器页面中收到错误,即 localhost 拒绝连接

【问题讨论】:

  • 请尝试重启你的机器和xampp。
  • 你确定网址是http://localhost:85/CodeIgniter-3.0.1/CodeIgniter3.0.1/index.php/...吗?应该是http://localhost/index.php/

标签: php codeigniter session


【解决方案1】:

改变你的路线:

$route['sessionex'] = 'Session_Controller/index';
$route['sessionex/unset'] = 'Session_Controller/unset_session_data';

【讨论】:

    猜你喜欢
    • 2017-01-22
    • 2017-11-10
    • 1970-01-01
    • 1970-01-01
    • 2018-10-17
    • 2021-02-20
    • 2023-02-05
    • 2013-11-04
    • 1970-01-01
    相关资源
    最近更新 更多