Welcome Guest, Not a member yet? Register   Sign In
Disable IP address, user-agent string in cookie
#1

Hi, 
 I'm working with CI 3.0 and I have a problem with GDPR policies
 I'd like to avoid CI store the IP address and User Agent of client in cookie.

I try to set config : 

Code:
$config['sess_match_ip']    = FALSE;
$config['sess_match_useragent']    = FALSE;


But cookie still store IP address and User Agent.

Also I found the code to set cookie with IP address and User Agent in function sess_create() in Session.php 

PHP Code:
function sess_create()
 
   {
 
       $sessid '';
 
       while (strlen($sessid) < 32)
 
       {
 
           $sessid .= mt_rand(0mt_getrandmax());
 
       }

 
       // To make the session ID even more secure we'll combine it with the user's IP
 
       $sessid .= $this->CI->input->ip_address();

 
       $this->userdata = array(
 
           'session_id'    => md5(uniqid($sessidTRUE)),
 
           'ip_address'    => $this->CI->input->ip_address(),
 
           'user_agent'    => substr($this->CI->input->user_agent(), 0120),
 
           'last_activity'    => $this->now,
 
           'user_data'        => ''
 
       );


 
       // Save the data to the DB if needed
 
       if ($this->sess_use_database === TRUE)
 
       {
 
           $this->CI->db->query($this->CI->db->insert_string($this->sess_table_name$this->userdata));
 
       }

 
       // Write the cookie
 
       $this->_set_cookie();
 
   

 Is there any config to affect above code ?
 I need to keep the cookie without IP address and UA ,
 Can anyone tell me how to avoid CI store the IP address and User Agent in Cookie.
 Thanks in advance.
Reply
#2

In the config.php file the session array sess_match_ip should be false.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(06-07-2018, 03:17 AM)yoyovolam Wrote: Hi, 
 I'm working with CI 3.0 and I have a problem with GDPR policies
 I'd like to avoid CI store the IP address and User Agent of client in cookie.

I try to set config : 

Code:
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = FALSE;


But cookie still store IP address and User Agent.

Also I found the code to set cookie with IP address and User Agent in function sess_create() in Session.php 

PHP Code:
function sess_create()
 
   {
 
       $sessid '';
 
       while (strlen($sessid) < 32)
 
       {
 
           $sessid .= mt_rand(0mt_getrandmax());
 
       }

 
       // To make the session ID even more secure we'll combine it with the user's IP
 
       $sessid .= $this->CI->input->ip_address();

 
       $this->userdata = array(
 
           'session_id' => md5(uniqid($sessidTRUE)),
 
           'ip_address' => $this->CI->input->ip_address(),
 
           'user_agent' => substr($this->CI->input->user_agent(), 0120),
 
           'last_activity' => $this->now,
 
           'user_data' => ''
 
       );


 
       // Save the data to the DB if needed
 
       if ($this->sess_use_database === TRUE)
 
       {
 
           $this->CI->db->query($this->CI->db->insert_string($this->sess_table_name$this->userdata));
 
       }

 
       // Write the cookie
 
       $this->_set_cookie();
 
   

 Is there any config to affect above code ?
 I need to keep the cookie without IP address and UA ,
 Can anyone tell me how to avoid CI store the IP address and User Agent in Cookie.
 Thanks in advance.

Update the Codeigniter Version. You using Codeigniter 2 and not 3
Reply




Theme © iAndrew 2016 - Forum software by © MyBB