Post by danijr » Fri Mar 02, 2018 11:05 pm

Hello, i wonder how to extend the time of products, for example, 30 days in the cart with the help session.php set cookie and save file a on my host.

I changed the file session.php __consctuct()!

Code: Select all

		if ($this->adaptor && !session_id()) {
			ini_set('session.use_only_cookies', 'Off');
			ini_set('session.use_cookies', 'On');
			ini_set('session.use_trans_sid', 'Off');
			ini_set('session.cookie_httponly', 'On');
		
			if (isset($_COOKIE[session_name()]) && !preg_match('/^[a-zA-Z0-9,\-]{22,52}$/', $_COOKIE[session_name()])) {
				exit('Error: Invalid session ID!');
			}
			
			session_set_cookie_params(0, '/my_sessions');
			
			ini_set('session.cache_expire', '1');
            ini_set('session.gc_maxlifetime', '60');
            ini_set('session.save_path',DIR_SYSTEM.'my_sessions');
			session_save_path(realpath(dirname($_SERVER['DOCUMENT_ROOT']) . '/my_sessions'));
			session_start();
		}		
But not working for me, why is not working :(

New member

Posts

Joined
Fri Dec 02, 2016 10:28 pm

Post by straightlight » Sat Mar 03, 2018 8:27 am

__consctuct()
This method name does not exist and even less by using the __ in front with an unknown method name. This will throw a PHP error from the error triggers.
But not working for me, why is not working
Because you are not posting enough information so for people to understand the source of the issue.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by danijr » Mon Mar 05, 2018 3:24 pm

Seriously? I thought everyone here understood MVC

How the products added to your cart will stay for 30 days? :)
https://imgur.com/a/l8jpU

New member

Posts

Joined
Fri Dec 02, 2016 10:28 pm

Post by straightlight » Mon Mar 05, 2018 7:57 pm

danijr wrote:
Mon Mar 05, 2018 3:24 pm
Seriously? I thought everyone here understood MVC

How the products added to your cart will stay for 30 days? :)
https://imgur.com/a/l8jpU
Nice workflow. Although, very serious to say that this methodology you're trying to achieve is flaw.

- The cart table uses a token and not recommended, and useless in this case, to extend its time-to-live length
- Guest users can still close their browsers and won't keep the extended length other than for a short temporary period after closing the browser
- The system/library/cart/cart.php file already has a defined setting of maximum time of 1 hour to clear the cart table on the affected rows for guest users

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by danijr » Tue Mar 06, 2018 3:15 pm

That's exactly what I noticed, how to extend this session?

// Remove all the expired carts with no customer ID
$this->db->query("DELETE FROM " . DB_PREFIX . "cart WHERE (api_id > '0' OR customer_id = '0') AND date_added < DATE_SUB(NOW(), INTERVAL 100 HOUR)");

session_set_cookie_params(0, '/my_sessions'); = > session_set_cookie_params(60*60*24, '/my_sessions');


session.gc_maxlifetime = 2592000
session.cookie_lifetime = 2592000

New member

Posts

Joined
Fri Dec 02, 2016 10:28 pm
Who is online

Users browsing this forum: stevequah and 56 guests