0

I'm getting the current date-time.but not getting the ip address....the output is ::1 ..why this is happening ?enter image description here

<?php 
  defined('BASEPATH') or exit('No Direct Script Access Allowed');

  class Ip_address extends CI_Controller {

    function __construct() {
      parent::__construct();
      $this->load->helper('url');
    }

    public function index(){
      // var_dump($_SERVER);
      $this->load->helper('date');
      echo $date = "Current Time Is: ". date('Y-m-d H:i:s');
      echo "<br/>"; 
      echo $this->input->ip_address();
    }
  }

2 Answers2

1

The IP ip of ::1 is identical to 127.0.0.1. If you want see the address like 192.168.x.x then you may try with another computer for example you set computer A as local server then you open the system on computer B (must be on the same network), you will see the different address printed.

You may try and give feedback.

Nere
  • 4,097
  • 5
  • 31
  • 71
0

Your Apache is listening for IPv6 connections by default (::1 i.e. localhost). If you just want IPv4, try to disable IPv6 connections in your Apache configuration.

If you want to get a different IP address, then you'll need to connect to the server through a different network interface.

Muhammad Usman
  • 1,403
  • 13
  • 24