Many users may find that their ecshop often times out when they are turned off. There are many ways to solve this problem. We can modify it directly in ecsho. The specific method is as follows
Modify it in includescls_session.php
The code is as follows
代码如下 |
复制代码 |
var $max_life_time = 1440;
|
|
Copy code
|
var $max_life_time = 1440;
// SESSION expiration time, the number in this code in seconds. The unit of this number is seconds. Foreground login and background login are the times set here.
2 Regarding editing products in the background that often times out due to long time, you can select "Please save my login information this time" when logging in to avoid the timeout prompt, or directly modify admintemplateslogin.html to make the page This option is selected by default! The current new version has a higher level of security. It takes almost 5 minutes to log in again without operating the background. Is there any way to change it? Because it only takes 3 minutes, we often time out during the entry process, so we need to increase the timeout. time.
The modification method is as follows:
代码如下 |
复制代码 |
@ini_set(’session.cache_expire’, 180);//单位秒
|
includes/init.php
api/init.php
admin/includes/init.php
wap/includes/init.php
代码如下 |
复制代码 |
ini_set('session.gc_maxlifetime', 3600); //设置时间
ini_get('session.gc_maxlifetime');//得到ini中设定值
?>
|
In the above files, find the following code
The code is as follows
|
Copy code
代码如下 |
复制代码 |
function start_session($expire = 0)
{
if ($expire == 0) {
$expire = ini_get('session.gc_maxlifetime');
} else {
ini_set('session.gc_maxlifetime', $expire);
}
if (empty($_COOKIE['PHPSESSID'])) {
session_set_cookie_params($expire);
session_start();
} else {
session_start();
setcookie('PHPSESSID', session_id(), time() + $expire);
}
}
?>
|
|
@ini_set(’session.cache_expire’, 180);//Unit seconds
|
Of course, in addition to the above method, we can also modify the php configuration file to operate
Continuing with the Session topic in PHP, the life cycle of the Session is mainly set in PHP by setting session.gc_maxlifetime. For example:
The code is as follows
|
Copy code
|
ini_set('session.gc_maxlifetime', 3600); //Set time<🎜>
ini_get('session.gc_maxlifetime');//Get the value set in ini<🎜>
?>
The following is a function packaged by others, but I have not tested it. It is for reference only:
The code is as follows
|
Copy code
|
Function start_session($expire = 0)<🎜>
{<🎜>
If ($expire == 0) {<🎜>
$expire = ini_get('session.gc_maxlifetime');<🎜>
} else {<🎜>
ini_set('session.gc_maxlifetime', $expire);<🎜>
}<🎜>
<🎜>
If (empty($_COOKIE['PHPSESSID'])) {<🎜>
Session_set_cookie_params($expire);<🎜>
Session_start();<🎜>
} else {<🎜>
Session_start();<🎜>
setcookie('PHPSESSID', session_id(), time() + $expire);<🎜>
}<🎜>
}<🎜>
?>
How to use:
Add start_session(600); //Expires after 600 seconds.
http://www.bkjia.com/PHPjc/633206.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/633206.htmlTechArticleMany users may find that their ecshop often times out after using it. There are many solutions to this problem. We can modify it directly in ecsho. The specific method is as follows...
|
|
|