note 67191 added to function.setcookie

From: Date: Mon, 05 Jun 2006 14:38:58 +0000
Subject: note 67191 added to function.setcookie
Groups: php.notes 
Request: Send a blank email to php-notes+get-113242@lists.php.net to get a copy of this message
You can use cookies to prevent a browser refresh repeating some action from a form post... (providing the client is cookie enabled!) //Flag up repeat actions (like credit card transaction, etc) if(count($_POST)>0) { $lastpost= isset($_COOKIE['lastpost']) ? $_COOKIE['lastpost'] : ''; if($lastpost!=md5(serialize($_POST))) { setcookie('lastpost', md5(serialize($_POST))); $_POST['_REPEATED']=0; } else { $_POST['_REPEATED']=1; } } //At this point, if $_POST['_REPEATED']==1, then the user //has hit the refresh button; so don't do any actions that you don't //want to repeat! Hope that helps :) Gareth ---- Server IP: 219.239.98.8 Probable Submitter: 60.183.138.134 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.setcookie.php Edit -- http://master.php.net/note/edit/67191 Del: integrated -- http://master.php.net/note/delete/67191/integrated Del: useless -- http://master.php.net/note/delete/67191/useless Del: bad code -- http://master.php.net/note/delete/67191/bad+code Del: spam -- http://master.php.net/note/delete/67191/spam Del: non-english -- http://master.php.net/note/delete/67191/non-english Del: in docs -- http://master.php.net/note/delete/67191/in+docs Del: other reasons-- http://master.php.net/note/delete/67191 Reject -- http://master.php.net/note/reject/67191 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#113242) next »