<p>I'm not clear on what you're asking.</p>

<p>A user's cart is created as soon as they land on any page that has <code>{% set cart = craft.commerce.cart %}</code> in it; whether they are a logged in user or not. Carts are not attached to Users until the order is complete (and only if you were a logged in user). You can have a cart as a guest, add to it, then log in and you'll still have the same cart.</p>

<p>Are you saying that you want someone to fill out a cart, pay for it, complete the order - then be logged out immediately? Why? If they complete an order and then make another order it will already be a different cart.</p>

CC BY-SA 3.0
2016-10-23T01:52:39.623Z
That is what I had wanted, the way the site works, having a cart with multiple items wouldn't work, so they would add to the cart, pay, and then I wanted to log them out. I found a work around for this uniquely strange checkout. Although, It is something I would like to know for future reference. The cart can expire, but It would be nice to have that control, if needed.
SpoonShoe
CC BY-SA 3.0
2016-10-21T16:26:27.790Z
2016-10-21T18:23:16.340Z
2016-10-21T18:23:16.340Z
Matt Wilcox
<p>In the sample code, Logout doesn't actually do anything. Once a user has created a cart / order and the go to a different page, I want to force log them out, so if they go back to the cart page, it's a new order etc where they have to enter their email in again. Thanks</p>

<plugin-craftcommerce>
How do I log out a guest user?
# How do I log out a guest user?

(Asked by: username_0 on 2016-10-20)

In the sample code, Logout doesn't actually do anything. Once a user has created a cart / order and the go to a different page, I want to force log them out, so if they go back to the cart page, it's a new order etc where they have to enter their email in again. Thanks

**Tags:** plugin-craftcommerce


---

## 1 answers

### Answer by username_1 on 2016-10-21. Score: 2

I'm not clear on what you're asking.

A user's cart is created as soon as they land on any page that has `{% set cart = craft.commerce.cart %}` in it; whether they are a logged in user or not. Carts are not attached to Users until the order is complete (and only if you were a logged in user). You can have a cart as a guest, add to it, then log in and you'll still have the same cart.

Are you saying that you want someone to fill out a cart, pay for it, complete the order - then be logged out immediately? Why? If they complete an order and then make another order it will already be a different cart.

> **Comments:**
> **username_0**: That is what I had wanted, the way the site works, having a cart with multiple items wouldn't work, so they would add to the cart, pay, and then I wanted to log them out. I found a work around for this uniquely strange checkout. Although, It is something I would like to know for future reference. The cart can expire, but It would be nice to have that control, if needed.  

---

