Forum
Logging out buyer after displaying their order confirmation
I've made a shop with a no-account checkout.
Everything is fine but I'd like to log the user out after their payment and order confirmation is displayed, so that their address details aren't hanging around in the browser. I've used this:
if (perch_shop_order_successful()) {
perch_content('Order successful');
perch_shop_order_items(
perch_shop_successful_order_id()
);
perch_shop_set_cart_property('terms_agreed', null);
perch_shop_empty_cart();
perch_member_log_out();
}else{
When I do this I get the message about headers already sent. However, if I use the log out command at the top of the page the order details aren't output.
If I leave out the log_out line, the page works fine otherwise.
Is there a way to do this?
Logging out involves modifying the cookie, which needs to be done while the headers are still being output.
You can output the order details to a variable, log the member out, and then echo that variable further down the page.