我的会话在我的控制器上使用此代码后到期:
header("Location: $url?$params");
这是让我去网站的主要功能。在完成一些过程之后,它会将其重定向回我的网站。但是我的会话到期了。这背后的主要问题是什么?
以下是我的config.php上的会话设置
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = FALSE;
$config['sess_table_name'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;
答案 0 :(得分:1)
您需要更改此配置:
$config['sess_match_useragent'] = TRUE;
要:
$config['sess_match_useragent'] = FALSE;
试试这个并希望它能解决你的问题。
答案 1 :(得分:0)
Jerahmeel Acebuche,据我所知,我可以举个例子,如果用户首先没有启用cookie,那么cookie将被取消,因为URL中携带的会话ID将消失。您需要检查SID是否已设置,如果已设置,请将其与URL一起使用。这里;使用我的函数而不是header():
PHP代码:
// perform redirect- supports no cookies AND works with older browsers, too (nice!)
function _location($url, $params = '') {
if(strlen(SID)) {
if (strlen($params)) {
$params = '?'.$params.'&'.SID;
} else {
$params = '?'.SID;
}
} else {
if (strlen($params)) {
$params = '?'.$params;
}
}
header("Location: ".$url.$params);
echo "<h3>You are using an old browser that does not support redirection.
Have you thought about upgrading?<br><br>
<a href='".$url.$params."'>Click here to continue using the site.</a></h3>";
die; // never return, no matter what
}
use it like this: _location('debug.php','flag=true')
--note that second argument is optional but you can pass GEt-style variables
this way.to find out what I'm doing here be sure to read php.net/session
good luck,
Jerahmeel Acebuche