php - Time Limit On Page -


i run online gaming website , trying stop users being able reload page on , on again. thought way add timestamp variable url , if users presses try again, update timestamp.

i trying make if timestamp within 5 minutes script allow them access, if timestamp in url outside 5 minute limit, script die , produce error. have searched , found ideas have implemented, still able use same url after 30 minutes. urls ends this: id players id number , t unix timestamp

mug.php?id=186&t=1368036608 

this have in code in order try put in place , hope clear enough on trying do. timestamp in url not update upon refresh, timestamps point press mug button, believe right.

include "globals.php"; $_get['id'] = isset($_get['id']) && is_numeric($_get['id']) ? abs(@intval($_get['id'])) : false; $_get['t'] = isset($_get['t']) && is_numeric($_get['t']) ? abs(@intval($_get['t'])) : false;  $time = time(); $time2 = $_get['t']; $futuretime = $time2+(60*5);  if($futuretime < $time2) { print "session expired. please go profile page , press mug button again. "; die(); } 

you should hold timestamp in session not in url can altered. maybe better:

if (!session_id()) {     session_start(); }  $currenttimestamp = $_server['request_time']; $allowtimeframe = 300; $nexttimestamp = $currenttimestamp + $allowtimeframe; $timestamp = isset($_session['ac_timestamp']) ? $_session['ac_timestamp'] : 0;  if ($currenttimestamp < $timestamp) {    exit('please not refresh page within ' . ($allowtimeframe/60) .' minutes'); }  $_session['ac_timestamp'] = $nexttimestamp; 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -