• Anyone have a good idea how to get rid of cookies once someone checks out? This is for an intranet and company policy dictates no cookies left on the client machine. We can use them during the purchase and at checkout, but they can’t be left on the buyer’s computer after checkout is complete.

    https://wordpress.org/plugins/woocommerce/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    Cookies in WooCommerce are session based. They will be removed when the browser is closed.

    Thread Starter Squiggy45

    (@squiggy45)

    That’s not quite correct, but it’s better than I thought. There is at least one cookie, “wp_woocommerce_session”, that expires 2 days after it’s created, regardless of whether or not the browser is closed. Is there any way to clear that when the browser is closed?

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    Ah yes.

    So you have a few options but need to do some coding.

    You could create a custom session handler to replace https://github.com/woothemes/woocommerce/blob/master/includes/class-wc-session-handler.php

    Or you could try clearing all cookies on the thanks page after payment or using a hook.

    This perhaps https://github.com/woothemes/woocommerce/blob/730019ef18462c553b6946ef5ee245c473238e06/includes/class-wc-cart.php#L304

    Thread Starter Squiggy45

    (@squiggy45)

    I appreciate the reply. Those seem a bit complicated (for me at least – probably simple for others). I’m using SSO to allow employees of an intranet to log in from their portal from a link that sends post information.

    It turns out that if they use a different employee number from the same computer, the previous user’s session is being displayed in Woocommerce, so I’m just trying to clear that cookie after a shorter period, or when the browser closes, or when a new user comes in via SSO. I’ll see if the SSO developer can work on that.

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    I think you should use the woocommerce_cart_emptied action. E.g.

    add_action( 'woocommerce_cart_emptied', 'custom_remove_cookies' );
    
    function custom_remove_cookies() {
    // remove cookies here
    }
    Thread Starter Squiggy45

    (@squiggy45)

    It’s a good idea, but there are thousands of employees, and many will put things in their cart, not complete the transaction, and then we’re back in the same situation.

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    I guess you need to go the custom session handler route in that case.

    Of course, another alternative would be to require logins, but you’d need to make sure people logout after purchase which is a similar issue.

    if you need some customisation work done, try jobs.wordpress.net. Perhaps someone can make a custom handler with no time based cookie expiration.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Cookies’ is closed to new replies.