Dear readers,
I would like to extend the duration of the sessions/cookies for the shopping cart of my webshop for x days or possibly months. This will increase, in my view, the conversion and will match the trend of people using their carts as whishlists.
I notice that in large e-commerce shops cookies/sessions also be kept long, how do I get this done?
Thanks for reading and thinking with me about this issue.
Kind regards,
Kevin
Open your php.ini file and edit the session.gc_maxlifetime. The value is in number of seconds.
There are two things to remember:
1. Setting this value to a long period can cause issues on your server from number of files/used space. Session files are small but tens or hundreds of thousands of them add up.
2. Once the user closes their browser the session is expired anyway so setting it for more than a few hours, maybe a day or two, isn't worth it.
There are two things to remember:
1. Setting this value to a long period can cause issues on your server from number of files/used space. Session files are small but tens or hundreds of thousands of them add up.
2. Once the user closes their browser the session is expired anyway so setting it for more than a few hours, maybe a day or two, isn't worth it.
-Ryan
Hi rph,
Thanks for your answer.
Is it possible to keep the products in the cart, even if the browser is closed? With the help of cookies maybe?
I currently experience the longer duration of the cart (even when the browser is closed) on big e-commerce sites and i think it is a must for every shop.
Hopefully there is some tweak to fix it.
Thanks for your answer.
Is it possible to keep the products in the cart, even if the browser is closed? With the help of cookies maybe?
I currently experience the longer duration of the cart (even when the browser is closed) on big e-commerce sites and i think it is a must for every shop.
Hopefully there is some tweak to fix it.
You can try messing with the session_set_cookie_params() value in the Session class. It didn't work for me on some quick testing so you'll need to do some research on persisting it after a browser close.
-Ryan
I too want to extend the session length for customer carts. There is a solution on Reboot.ro that extends the cart and admin session.
First, check your phpinfo.php file to see what session.cache_expire, session.gc_maxlifetime, session.cookie_lifetime and session.save_path is set to. If you are unable to affect the values using other solutions, then you will need go to your cpanel and look for the php settings and add the values there. For example, I'm running on Plesk 12 and I have to go to each domain (multi-stores) and modify the php settings for the session.gc_maxlifetime, session.save_path and session.cookie_lifetime. By doing this, I don't really have to include them in the session.php file as shown below, but I do however set the session_set_cookie_params to 86400 seconds (one day). So in short, it depends on whether your server overrides the php.ini settings. In my case it does and the only way to change them is in the cpanel.
Step 1: Locate system/library/session.php
Find:
Replace with:
Step 2: You need to create a folder /your_path/public_html/sessions with 777 permissions.
Step 3: Check to see if the values changed in your phpinfo.php file (note: if you don't see changes, then you need to go to your server cpanel and check the php settings).
Reference Credit: http://www.reboot.ro/troubleshooting/so ... n-timeout/
First, check your phpinfo.php file to see what session.cache_expire, session.gc_maxlifetime, session.cookie_lifetime and session.save_path is set to. If you are unable to affect the values using other solutions, then you will need go to your cpanel and look for the php settings and add the values there. For example, I'm running on Plesk 12 and I have to go to each domain (multi-stores) and modify the php settings for the session.gc_maxlifetime, session.save_path and session.cookie_lifetime. By doing this, I don't really have to include them in the session.php file as shown below, but I do however set the session_set_cookie_params to 86400 seconds (one day). So in short, it depends on whether your server overrides the php.ini settings. In my case it does and the only way to change them is in the cpanel.
Step 1: Locate system/library/session.php
Find:
Code: Select all
<?php
class Session {
public $data = array();
public function __construct() {
if (!session_id()) {
ini_set('session.use_cookies', 'On');
ini_set('session.use_trans_sid', 'Off');
session_set_cookie_params(0, '/');
session_start();
}
$this->data =& $_SESSION;
}
function getId() {
return session_id();
}
}
?>
Code: Select all
<?php
class Session {
public $data = array();
public function __construct() {
if (!session_id()) {
ini_set('session.use_cookies', 'On');
ini_set('session.use_trans_sid', 'Off');
/* Q-mod -- session extend */
session_set_cookie_params(86400, '/');
ini_set('session.cache_expire', '180');
ini_set('session.gc_maxlifetime', '86400');
ini_set('session.save_path','/your_path/public_html/sessions');
session_start();
}
$this->data =& $_SESSION;
}
function getId() {
return session_id();
}
}
?>
Step 3: Check to see if the values changed in your phpinfo.php file (note: if you don't see changes, then you need to go to your server cpanel and check the php settings).
Reference Credit: http://www.reboot.ro/troubleshooting/so ... n-timeout/
Vorticy, Inc.
Opencart 1.5.6.4, MySQL 5.1.73-5, PHP 5.3.3-46, Plesk v12.0.18, OS CentOS 6
Who is online
Users browsing this forum: No registered users and 110 guests