PDA

View Full Version : Prevent Refresh


PTGigi
01-27-2011, 08:23 PM
Okay so I wasn't sure if this was a question or a suggestion so I'll throw it out.


I'm in the middle of coding something and REALLY need a way to disable refreshing, basically I don't want cheaters. (because I have a page that gives you an adoptable but I do not want you to get it twice through refresh, I suppose this could also be added to the 'congrats you've adopted ___" page but really I'd like it if someone could help out XD

I assume there isn't an exact way to do this since it involves messing with people's browsers. But is it possible to make a pop-up message when you hit F5 or refresh appear and say 'refreshing disabled' or whatnot? Or somehow make a way to remove the given adoptable if you refresh the page?

Anymore ideas or suggestions or anyone know of a way to do this? O.o Javascript will also work though all my Google searching only disheartened me (apparently this technique is mainly used by scam and porn sites T_T)

EDIT: Mrf, just thought of something else.

Is it possible (I've been trying but failing) to make some sort of variable that adds up as you visit the page? Sorta like the log-in attempts on forums?

HIddenPanda
01-27-2011, 10:38 PM
Well, about the refresh thing... It's pretty much impossible (as of what i've read on it) and For the attempts thing... use a session or a cookie... (cookies you can clear/edit so I suggest using a session) There easier then they look... mostly

fadillzzz
01-28-2011, 02:10 AM
Yep! The best way is to use session..

Hall of Famer
01-28-2011, 08:36 AM
Yeah, you will have to use sessions. They are rather complicated to implement though, ask a PHP coder for help if you want to.

PTGigi
01-28-2011, 10:07 AM
Alright thanks guys :D *goes to learn about session* X3

Kaeliah
01-28-2011, 10:21 AM
Another possibility is using a redirect. It takes you away from the page that you don't want to be refreshed immediately, and even if you back up it should still redirect you. Then again Javascript can be disabled so... ^.^ You'd have to have some pretty dedicated cheaters. But Sessions work too, they're just more complex.

PTGigi
01-28-2011, 10:26 AM
I was thinking about that XD Lol I'm probably over thinking this as well XD I don't know how many users think 'refesh!' XD But thanks anyway guys :D I'll probably end up doing the redirect (since I was planning on that for another page anyway :meow:)

fadillzzz
01-28-2011, 11:28 AM
If you're worried that the users have javascript disabled, then use the PHP header function to do the redirection
and session isn't really that hard to implement actually...

Hall of Famer
01-28-2011, 11:38 AM
Sounds really interesting, maybe it will work for my fishing system too. ^^

HIddenPanda
01-28-2011, 04:12 PM
yes fadillz is right you can simply use

header("Location: page.php");