Solution to ecshop background login timeout and session expiration_PHP tutorial

WBOY
Release: 2016-07-13 10:42:59
Original
1286 people have browsed it

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.

www.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...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!