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
how to change session time
Moderator: General Moderators
-
nowaydown1
- Forum Contributor
- Posts: 169
- Joined: Sun Apr 27, 2008 1:22 am
Re: how to change session time
I believe you actually want session.cookie_lifetime:
Code: Select all
ini_set( 'session.cookie_lifetime', 3600 * 24 );
-
WebbieDave
- Forum Contributor
- Posts: 213
- Joined: Sun Jul 15, 2007 7:07 am
Re: how to change session time
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);
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
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.....
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
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......
...then also it's not happening...whwether we can use session & cookie in one page?
help me......