humbleiam
humbleiam

Reputation: 1009

Create infinite sessions in codeigniter php framework

I am trying to create a session last forever in php, with codeignter framework.

My session settings at config.php are :

$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'org_session';
$config['sess_expiration'] = 0;
$config['sess_save_path'] = 'org_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

Eventhough the expiration is zero, still session expires after browser closes. Any idea how to make this work? I am use mysql database to store session data.

Upvotes: 1

Views: 707

Answers (2)

B.Jimenez
B.Jimenez

Reputation: 11

I think using conditions, if the ip adress an the cookies params have especific info then redirect index page, and not to login page

if($ipaddress == 'foo' && $cookie['infinity'] == 'true'){
  $info= $model->getuser($ipaddress);
  if($info){
    redirect('index.php');
  }else{
    redirect('login.php);
  }
}

Upvotes: 0

Jaymin
Jaymin

Reputation: 1661

According to Manual

The value 0 means "until the browser is closed." Defaults to 0.

Upvotes: 1

Related Questions