Welcome Guest, Not a member yet? Register   Sign In
[Solved] Codeigniter not setting correct expire time for cookie
#1

(This post was last modified: 04-09-2017, 09:08 PM by wolfgang1983.)

I am using google chrome. And xampp with windows 10

For some reason the expire time is not set correct for cookie

2017-04-10T11:17:38.801Z its not setting it correct

[Image: 3IWlymI5mwva.png]

I have done this below. I am trying to get it to expire in 12 hours no luck

Question how to make sure it can set the expire time correct.


PHP Code:
$cookie_input = array(
'name' => $this->cookie_name, 
'value' => $data, 
'expire' => '43200', 
'domain' => '.project-ask.com',
'path' => '/', 
'prefix' => 'ci_'
);

$this->CI->input->set_cookie($cookie_input); 


On my config.php session


PHP Code:
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 1440;
$config['sess_save_path'] = APPPATH 'cache/session/';
$config['sess_match_ip'] = TRUE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = TRUE;
 
$config
['cookie_prefix'] = '';
$config['cookie_domain'] = '';
$config['cookie_path'] = '/';
$config['cookie_secure'] = FALSE;
$config['cookie_httponly'] = FALSE

This function


PHP Code:
private function write_cookie($data = array()) {
    $data serialize($data);

     if ($this->cookie_encrypt) {
       $this->CI->load->library('encryption');
       $data $this->CI->encryption->encrypt($data);
     }

    $cookie_input = array(
        'name' => $this->cookie_name, 
        
'value' => $data, 
        
'expire' => '43200', 
        
'domain' => '.project-ask.com',
        'path' => '/', 
        
'prefix' => 'ci_'
    );

    return $this->CI->input->set_cookie($cookie_input);
}
  
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#2

(This post was last modified: 04-09-2017, 09:08 PM by wolfgang1983.)

I have got it working now so far I was using the input->set_cookie(). For me that was causing a bit of issue now using the cookie helper seems to set correct times and other stuff as well.

On my Client.php library

PHP Code:
public function write_cookie($data = array()) {
        $data serialize($data);

        $data $this->CI->encryption->encrypt($data);
      
        $cookie_input 
= array(
        'name' => $this->cookie_name, 
        
'value' => $data, 
        
'expire' =>'86500', 
        
'domain' => '.project-ask.com',
        'path' => '/', 
        
'prefix' => $this->prefix
        
);

        return set_cookie($cookie_input);

There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB