简体   繁体   中英

localhost refused to connect on xampp issue

I have tried to create a session example on Codeigniter php, this is my Sesion_controller.php code.

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'); 
  }         
}

This is my Session-view.php code

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

Following changes I made in routes.php file

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

After running this code in my local server, the view page properly run but I get an error in controller page ie localhost refused to connect

Change your route:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM