Show Your Booking Cart on Your Main Website
Someone picks a 20 yard, adds it to the cart, then clicks back to your website to double check whether you take concrete. They read the page, they are satisfied, and now they are on your site with a half-finished order sitting on another domain and absolutely nothing on screen telling them so.
Putting a live dumpster rental booking cart indicator in your website navigation is very doable, but the obvious approach cannot work, and the reason is a browser security rule rather than a limitation of your booking software. Once you know what that rule is, the fix is about fifteen lines of code.
Quick Answer · TL;DR
Your website cannot read your booking system’s session. It can read a cookie the booking system writes for it.
- Booking platforms keep the cart in a session cookie marked HttpOnly, which JavaScript is forbidden from reading.
- That is why a cart badge on your marketing site usually gets abandoned as impossible.
- If both sites sit on the same registrable domain, the booking side can write a plain cookie the website can read.
- No iframe, no API, no cross-origin requests involved.
- It only works if customers reach the booking system on your own subdomain rather than the vendor’s.
- Sync the count on a timer, because emptying a cart often does not reload the page.
- An empty cart usually renders no number at all, so absence has to be read as zero.
The Problem
An Abandoned Cart Nobody Can See
The gap is easy to miss because you never experience it yourself. You know the order is there. Your customer does not.
They cross back to your website to check a detail, and from that moment the booking cart is invisible. There is no icon, no count, no reminder. If they get distracted, which is the normal outcome, the order is simply gone. They did not decide against you. They just lost the thread, and nothing on the page picked it back up.
Every ecommerce site solves this with a cart icon and a number in the corner. The reason dumpster rental companies usually do not is that the two halves are on different systems, and the first attempt to connect them fails in a way that looks final.
Why the Obvious Fix Fails
You Are Not Allowed to Read That Cookie
The instinct is to read the booking system’s session cookie from your website and look up the cart. It seems reasonable. It cannot be done, and it is worth understanding why, because this is the point where most people conclude the whole idea is impossible.
Session cookies are set with the HttpOnly flag. That flag exists to blunt cross-site scripting attacks, and it tells the browser to send the cookie on requests but never expose it to JavaScript. It is not a configuration you can talk your way around. From your website, that cookie may as well not exist, in every browser, permanently.
So the session is closed to you. What is not closed is the page the booking system renders, which already displays the cart count in its own header. The booking system knows the number. It just has no reason to tell anyone else.
The Fix
Have the Booking Side Write a Cookie of Its Own
Cookies can be scoped to a parent domain. A cookie set on your booking subdomain with the domain attribute pointing at your registrable domain is readable by every subdomain underneath it, including your main website.
So the booking system reads its own cart count off the page it just rendered, writes that number into an ordinary readable cookie, and your website reads the cookie. No iframe, no API, no cross-origin request, nothing to authenticate.
document.cookie = "cart_count=" + count +
"; domain=.yourdomain.com; path=/; max-age=86400; SameSite=Lax; Secure";On the website side you read that cookie and toggle a badge. Repaint on page load, and again when the tab becomes visible, which covers someone switching back from the booking tab.
function paint() {
var m = document.cookie.match(/(?:^|;\s*)cart_count=(\d+)/);
var n = m ? parseInt(m[1], 10) : 0;
var badge = document.querySelector(".cart-badge");
badge.textContent = n > 99 ? "99+" : String(n);
badge.classList.toggle("is-visible", n > 0);
}
paint();
document.addEventListener("visibilitychange", function () {
if (!document.hidden) { paint(); }
});The one requirement you cannot code around
This works only when the booking system is served on your own subdomain. Plenty of platforms will also serve your store on a vendor domain, and some businesses end up linking to that one. A cookie scoped to your domain cannot be written from a hostname that does not share it, so the browser rejects the write and nothing happens. No error appears anywhere. If your badge never updates, check the hostname before you check anything else, and get the store onto your own subdomain.
The Two Traps
What Broke When I Built This
Syncing on page load is not enough
The first version wrote the cookie once when the page finished loading. It worked in testing, then showed a phantom item the moment a real cart was emptied.
Removing something from a cart often updates the page without a full reload. The count changes, no new page load happens, the cookie keeps its old value, and the website confidently displays an item that is no longer there. A badge that is wrong is worse than no badge, because it sends people to an empty cart.
Re-read the count on a short interval and write the cookie only when the number has actually changed. One second is plenty and costs nothing.
var last = -1;
function sync() {
var c = cartCount();
if (c === last) { return; }
last = c;
document.cookie = "cart_count=" + c +
"; domain=.yourdomain.com; path=/; max-age=86400; SameSite=Lax; Secure";
}
sync();
setInterval(sync, 1000);An empty cart renders no number at all
The second trap is in how you read the count. The header on these platforms tends to render something like Cart(2) when there are items, and plain Cart when there are none. There is no Cart(0) to find, so absence of a number has to be treated as zero.
That part is fine once you know it. The subtler mistake was where I looked. My first version read the visible text of the whole page, which skips anything hidden at the current screen width. On a layout where the cart indicator is hidden on desktop and shown on mobile, that returns a false zero and wipes a perfectly good badge.
Read the cart link element directly instead, and fall back to the page text only if that turns up nothing.
Both of those bugs shipped and both looked fine in testing, because I tested by loading pages rather than by using the cart. The lesson I keep relearning is that a feature which reflects changing state has to be tested by changing the state, not by reloading the page and admiring the result.
Know the Limits
What This Does Not Do
The badge is exactly as fresh as the customer’s last visit to a booking page. If they empty the cart and never return to the booking system, your website keeps showing the old number until the cookie expires. Set a sensible lifetime, a day is reasonable, and accept the tradeoff.
It is also per browser and per device. A cart started on a phone will not appear on a laptop. Real cross-device carts need an account system, which is a much larger project and rarely worth it at this size of business.
For the case that actually matters, which is someone bouncing between your site and your booking pages inside one session, it works and it costs almost nothing.
- Confirm your booking system is served on your own subdomain.
- Write the count into a readable cookie scoped to your registrable domain.
- Re-read the count on a timer, not only on page load.
- Read the cart element directly rather than the visible page text.
- Treat a missing number as zero, because empty carts render no count.
- Test by adding and removing items, not by reloading pages.
- Check the badge clears correctly when the last item is removed.
How We Handle Booking Software for Dumpster Rental Clients
Most of the money in dumpster rental marketing is lost after the click, in the gap between a good website and a booking system that was never designed to match it. We work on that seam, which means branding the booking pages, removing exits from the checkout, and closing the small gaps like this one where a customer loses track of an order they had already decided to place.
Want Me to Look at Your Booking Flow?
I will walk your booking pages the way a customer would, on a phone, from a search result through to a confirmed order, and tell you honestly where you are losing people. No charge and no obligation.
Give Them a Way Back
A customer who added a dumpster to a cart has already made the decision you spent money getting them to make. Losing that order to a missing icon is the cheapest possible way to lose a job.
One cookie, a timer, and a number in the corner of your header. That is the whole build.
Get contractor marketing tips in your inbox
SEO strategies, Google Ads insights, AI SEO updates, and practical marketing guides for home service contractors, delivered monthly. No fluff, no spam.
