Guides · BossCheck team · Updated 2026-10-14

How to Stop Players Editing Browser Game Saves to Unlock Paid Items

If your browser game decides what a player owns by reading localStorage or a cookie, any player can open dev tools and give themselves everything, including the paid items.

A real example

In October 2026, a developer on X described opening a vibe-coded browser game and finding the entire player state stored as a JSON string in the game's cookies. By editing it, they unlocked every item, including the paid ones, and changed their level and experience. No hacking tools were needed, just the browser.

This pattern is common in AI-built games because it's the simplest thing that works: save the state on the client, read it back on load, show whatever it says you own.

Why client-side saves can't be trusted

// What NOT to do
const save = JSON.parse(localStorage.getItem("save") || "{}");
if (save.premium) unlockAllLevels();          // player sets premium: true
if (save.owned?.includes("gold_skin")) equip("gold_skin");

Decide what actually needs protecting

For a purely offline, single-player game with no purchases or leaderboards, players editing their own save mostly hurts nobody, so local saves are fine. You need server-side state when the data involves money (paid items, premium unlocks, currency bought with real money), other players (leaderboards, trading, PvP) or rewards with real value.

The fix: server-side entitlements

Keep a table on your server that records what each account owns. The client asks the server; the server answers. The client's copy is only a cache for display.

// Server (e.g. Node/Express + any database)
app.get("/api/entitlements", requireAuth, async (req, res) => {
  const items = await db.entitlements.findMany({ where: { userId: req.user.id } });
  res.json({ items: items.map(i => i.sku) });
});

// Client: ask the server, don't read a local flag
const { items } = await (await fetch("/api/entitlements", { credentials: "include" })).json();
if (items.includes("gold_skin")) equip("gold_skin");

Any premium content (paid levels, assets) should also be served by an endpoint that checks the entitlement. Hiding a button doesn't help if the level data is already in the bundle.

Grant items only from a verified payment

Never unlock an item because the client says "payment succeeded" or because the player landed on a /success page; anyone can visit that URL. With Stripe, grant the item from a webhook and verify the signature, as Stripe's webhook docs require:

// Stripe webhook (Express). Use the raw body for signature checks.
app.post("/webhooks/stripe", express.raw({ type: "application/json" }), async (req, res) => {
  let event;
  try {
    event = stripe.webhooks.constructEvent(req.body, req.headers["stripe-signature"],
                                           process.env.STRIPE_WEBHOOK_SECRET);
  } catch { return res.status(400).send("Bad signature"); }

  if (event.type === "checkout.session.completed") {
    const s = event.data.object;
    if (s.payment_status === "paid") {
      // client_reference_id was set to your user ID when you created the session
      await db.entitlements.upsert({ userId: s.client_reference_id, sku: s.metadata.sku });
    }
  }
  res.sendStatus(200);
});

Set the price and SKU when you create the Checkout Session on the server, never from values the client sends. Store the session or payment ID so a replayed webhook can't grant twice. On mobile or platform stores, validate receipts server-side with the store's API instead.

Protect progress and currency too

Prompt to paste into your AI coding tool

Find every place this game reads ownership, purchases, premium status, currency,
level or XP from localStorage, sessionStorage, IndexedDB, cookies or a client-side
save file. Move purchases and paid unlocks to a server-side entitlements table
granted only by a signature-verified payment webhook, add an authenticated
endpoint the client uses to fetch entitlements, and serve paid content only after
checking that endpoint. Keep local storage only as a non-authoritative cache.

Want this checked automatically?

BossCheck is a security scanner for indie games built with AI tools. It's in pre-launch: join the waitlist for early access.

Join the waitlist →

FAQ

Can players edit localStorage in a browser game?

Yes. localStorage, sessionStorage, IndexedDB and cookies can all be viewed and changed in the browser's developer tools or console.

Does encrypting my save file stop cheating?

Not if the game decrypts it in the browser, because the key and the decryption code ship to every player. Only data checked or signed by your server can be trusted.

Are HttpOnly cookies safe from players?

HttpOnly stops page scripts from reading a cookie, which helps against XSS, but the player can still view and edit their own cookies in dev tools.

How do I unlock a paid item safely after a Stripe payment?

Grant it from a Stripe webhook whose signature you verify on the server, record it in an entitlements table tied to the user's account, and have the game read ownership from your server.

Do single-player offline games need this?

Usually not for progress, since players only affect themselves. You need server-side checks once there are real-money purchases, leaderboards or anything that affects other players.

More guides