Search code examples
wordpresswoocommercesession-cookies

Change wp_woocommerce_session_ Cookie


Woocoomerce sets the Cookie wp_woocommerce_session_ , the duration of this cookie is 2 days. It contains a unique code for each customer so that it knows where to find the cart data in the database for each customer.

How can it set the duaration to 7 days, so that the cart data is not deleted after 2 days?

Can anyone help me?


Solution

  • You can use the following filter:

    add_filter( 'wc_session_expiration', function(){
        return 60 * 60 * 24 * 7;
    });
    

    You'll find the source for that filter over here.