How did old flash games know if you refreshed your browser?

91 views

I remember a fun gimmick some old flash games used for puzzles. Particularly in “this is the only level” the door to the exit was locked until you refreshed the web browser. How did the game recognize this and then change the game state accordingly?

In: 1

Anonymous 0 Comments

There’s a local data method for nearly every web browser that saves to the computer. It lets the web browser save a limited amount into a private location in a file. It’s associated with the url of the site, so when the local data is requested or used it’s only messing with the save file of that url in particular.

It’s much like cookies, but more of a watered down version I believe. I’m not a professional programmer or anything, I just mess around for fun on occasion. Local data is really handy for someone like me who likes to make silly little programs the easy way.

Maybe they are using cookies or some other more professional method (although, I don’t see much harm in doing it the easy way for something like a simple game. It’s obviously not a huge security risk or anything like that.) It’s quite a simple thing to do.

Anyways, when the player reaches that point in the level, you can put a little “unlock_on_refresh = true” into the local data. You can have a small bit of code that only runs once when the page loads to check for that, and set the game accordingly.

I don’t believe it’s looking specifically for the page being refreshed, but rather looking for the page being visited with a condition set by a previous visit.