Nate M. Nate M. - 2 months ago 13
PHP Question

Trying to increase the session time of cart items (EDD & Wordpress)

I'm using WordPress and the Easy Digital Downloads plugin but the items in the cart are expiring after 30 minutes of inactivity, I want to increase this to something like 48 hours because 30 minutes is way too short for items in the cart to be removed.

I've ask on the EDD forums how to increase this expiration time but I'm just given links to add_filter tutorials that are not really helping me with this specific filter.

This is the filter I was told to tap into to change the expiration time:
https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/master/includes/class-edd-session.php#L93

So I've tried:

add_filter( 'wp_session_expiration_variant', array( 'WP_Session', '86400 * 60' ), 99999 );
add_filter( 'wp_session_expiration', array( 'WP_Session', '86400 * 60' ), 99999 );


and

add_filter( 'wp_session_expiration_variant', array( 'EDD_Session', '86400 * 60' ), 99999 );
add_filter( 'wp_session_expiration', array( 'EDD_Session', '86400 * 60' ), 99999 );


Neither works. Any ideas how to increase the session timeout?

Answer

Nothing was working for me so I hired someone to do it. This function increases the Easy Digital Downloads cart expiration to 48 hours:

add_filter( 'wp_session_expiration_variant', function() { return 46 * 60 * 60; }, 999999 );
add_filter( 'wp_session_expiration', function() { return 48 * 60 * 60; }, 999999 );
add_filter( 'edd_use_php_sessions', function() { return false; }, 999999 );
Comments