Page 1 of 1
how to change session time
Posted: Wed Jun 18, 2008 8:14 am
by php_dev1
hello,
i want to change session time.the session time should differ according to section of my module.
i have tried with this function ini_set('session.gc_maxlifetime'),but then also its not happening.
please help me.
thanks in advance
Re: how to change session time
Posted: Wed Jun 18, 2008 9:10 am
by nowaydown1
I believe you actually want session.cookie_lifetime:
Code: Select all
ini_set( 'session.cookie_lifetime', 3600 * 24 );
Re: how to change session time
Posted: Wed Jun 18, 2008 11:52 am
by WebbieDave
These are the settings that affect session length:
ini_set('session.cache_expire', (string)EXPIRE_LENGTH);
ini_set('session.gc_maxlifetime', (string)SESSION_LENGTH);
session_set_cookie_params(SESSION_LENGTH);
In addition to these, if you're on a shared server, your host may periodically empty the shared php sessions directory. To avoid this, if necessary, you can store sessions in alternate directory with:
session_save_path(SAVE_PATH);
Re: how to change session time
Posted: Thu Jun 19, 2008 12:51 am
by php_dev1
i have tried with these finction ini_set('session.gc_maxlifetime',7200),session_cache_expire( 5)
but nothing is happening...
in my proj,in all my modules session time upto 24 that one is default from php.ini file.but now for another module i want session time should be 8 hours...so what i have to do?
this is my code:
1.session_start();
$inactive = 28800;
if(isset($_SESSION['start']) ) {
$session_life = time() - $_SESSION['start'];
print_r($session_life);
if($session_life > $inactive){
session_cache_expire( 28800);
session_destroy();
header("Location: ems_home.php?<?= getSidParam($sid) ?>&ACTION=log_out_user");
}
}
$_SESSION['start'] = time();
2.$garbaze="28800";
ini_set('session.gc_maxlifetime',$garbaze);
$_SESSION['timeout'] =ini_get('session.gc_maxlifetime');
i am not getting what is wrong in my code...
plz help.....
Re: how to change session time
Posted: Thu Jun 19, 2008 7:40 am
by php_dev1
even i have tried with sesstion cookie using this function setcookie("TestCookie", $orgInfo[3], time()+28800);
...then also it's not happening...whwether we can use session & cookie in one page?
help me......