...

View Full Version : Anti refresh in PHP



masterofollies
01-31-2010, 12:13 AM
I am looking for something to prevent people from refreshing a page or inside a function.

Either by a pop up box saying refresh is disabled

or

By them being sent to another page stating refreshes are not allowed.

Dormilich
01-31-2010, 01:09 AM
if I were a user of your site, this would be the reason to never visit your site again.

masterofollies
01-31-2010, 01:12 AM
It's not for the whole website, it's for a single page only. I don't want the content to be sent twice.

seco
01-31-2010, 02:14 AM
what about if refferer is the same page dont send the content?

Len Whistler
01-31-2010, 02:43 AM
It's not for the whole website, it's for a single page only. I don't want the content to be sent twice.

Why? I think browsers cache stuff anyways to speed up the 2nd visit.




------------------

masterofollies
01-31-2010, 03:15 AM
@seco, it's a POST submit, I need it accessed a few times over, but refreshing is a cheat. Because I am using RAND.

@len once it's over and done with, they won't visit the page ever again

seco
01-31-2010, 03:42 AM
so is there content on this page they NEED to see?

masterofollies
01-31-2010, 04:05 AM
Yeah, this is what it does. It's an attack mode.

Enemy attacks you low. What do you want to do?
If you select Defend Low you block it and damage the enemy for 1/4 health, if you select the wrong move, you are damaged for 1/4 health.

There is a half dozen actions, confusing which one would be best for you. So if someone were to refresh the action, they could select the easiest one or the one they know is right multiple times.

Len Whistler
01-31-2010, 05:28 AM
The only thing I can think of is to use COOKIES or a SESSION to keep score.



-----------------

MattF
01-31-2010, 08:25 AM
I am looking for something to prevent people from refreshing a page or inside a function.

Either by a pop up box saying refresh is disabled

or

By them being sent to another page stating refreshes are not allowed.

You can't control a users browser. You have to log and divert server side. That means using sessions, logging activity to the DB etc. You'll need to keep track of their actions on that page somehow and work from there.

masterofollies
01-31-2010, 06:18 PM
My website does use SESSIONS. You have to login to access anything other than the front page. So since I use SESSIONS. How can I do it? :thumbsup:

MattF
01-31-2010, 10:31 PM
My website does use SESSIONS. You have to login to access anything other than the front page. So since I use SESSIONS. How can I do it? :thumbsup:

Set a session variable when they use that page and check for its existence each time the page is called. If it exists, then do whatever. You know they've been there. Header redirect, message etc.

Len Whistler
01-31-2010, 10:46 PM
Using sessions and mysql, it would be something like:

User starts the game and the session id is entered into database, along with other info such as ip address. I would also give each game an easy to remember id number, such as game id 49276. Example of a session id.

6a961341b0b7a08dbd7a2074289662f8

As the game is being played the score for game 49276 is updated only if the stored session id is equal to the current session id. Example:



// does 6a961341b0b7a08dbd7a2074289662f8 == 6a961341b0b7a08dbd7a2074289662f8
if ($row[session_id] == $session_id) {

// Play current game number 49276
} else {
// Start new game with new game number and session id generated. No more access to game 49276
}



If the browser is exited then game over, since a new session id will be generated.



-----------

masterofollies
01-31-2010, 11:59 PM
This is going to be confusing, let me try.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum