Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Resetting session based tests in PHP

I was writing and testing a PHP session based application - one in which a series of pages are linked together to make up a complete system - yesterday. And as ever with testing, bugs were found in the code and other things had to be added that meant it needed to be changed.

But it's rather different changing a session based applicaion between pages - in essence, you are modifying an application while it is running and that means that variables you need may not be set, and variables may be set when they should not be. And it almost certainly won't start testing back at the beginning.

The first options to solve the issue is to clear out your session cookie - probably called PHPSESSID if the application is in PHP - and start again. But that can be a lot of fiddling with the browser, and can result in other cookies that you would rather retain being lost. Here's an alternative I came up with - my page has a $_SESSION[current] variable through which I remember where I am in the task. And I simply added the "reset line" to my mode below.

if (! $_SESSION[current]) {
  $current = 0;
} else {
  $current = $_SESSION[current];
}
if ($_REQUEST[reset]) $current = 0;


And I can now restart my application (subject to remembering that not all of the old variables may be cleared!) by adding &reset=1 or ?reset=1 onto the end of the test URL.
(written 2007-08-26, updated 2007-08-28)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
H116 - Shopping Cart Application in PHP
  [1487] Efficient PHP applications - framework and example - (2007-12-28)
  [1623] PHP Techniques - a workshop - (2008-04-26)
  [1634] Kiss and Book - (2008-05-07)
  [3820] PHP sessions - a best practice teaching example - (2012-07-27)

H115 - Designing PHP-Based Solutions: Best Practice
  [123] Short underground journeys and a PHP book - (2004-11-19)
  [237] Crossfertilisation, PHP to Python - (2005-03-06)
  [261] Putting a form online - (2005-03-29)
  [340] Code and code maintainance efficiency - (2005-06-08)
  [394] A year on - should we offer certified PHP courses - (2005-07-28)
  [426] Robust checking of data entered by users - (2005-08-27)
  [563] Merging pictures using PHP and GD - (2006-01-13)
  [572] Giving the researcher power over database analysis - (2006-01-22)
  [839] Reporting on the 10 largest files or 10 top scores - (2006-08-20)
  [896] PHP - good coding practise and sticky radio buttons - (2006-10-17)
  [936] Global, Superglobal, Session variables - scope and persistance in PHP - (2006-11-21)
  [945] Code quality counts - (2006-11-26)
  [1047] Maintainable code - some positive advice - (2007-01-21)
  [1052] Learning to write secure, maintainable PHP - (2007-01-25)
  [1166] Back button - ensuring order are not submitted twice (PHP) - (2007-04-28)
  [1181] Good Programming practise - where to initialise variables - (2007-05-09)
  [1182] Painting a masterpiece in PHP - (2007-05-10)
  [1194] Drawing hands on a clock face - PHP - (2007-05-19)
  [1323] Easy handling of errors in PHP - (2007-08-27)
  [1381] Using a MySQL database to control mod_rewrite via PHP - (2007-10-06)
  [1389] Controlling and labelling Google maps via PHP - (2007-10-13)
  [1390] Converting from postal address to latitude / longitude - (2007-10-13)
  [1391] Ordnance Survey Grid Reference to Latitude / Longitude - (2007-10-14)
  [1482] A story about benchmarking PHP - (2007-12-23)
  [1490] Software to record day to day events and keep an action list - (2007-12-31)
  [1533] Short and sweet and sticky - PHP form input - (2008-02-06)
  [1694] Defensive coding techniques in PHP? - (2008-07-02)
  [1794] Refactoring - a PHP demo becomes a production page - (2008-09-12)
  [2199] Improving the structure of your early PHP programs - (2009-05-25)
  [2221] Adding a newsfeed for your users to a multipage PHP application - (2009-06-06)
  [2430] Not just a PHP program - a good web application - (2009-09-29)
  [2679] How to build a test harness into your PHP - (2010-03-16)
  [3539] Separating program and artwork in PHP - easier maintainance, and better for the user - (2011-12-05)
  [3813] Injection Attacks - PHP, SQL, HTML, Javascript - and how to neutralise them - (2012-07-22)
  [3926] Filtering PHP form inputs - three ways, but which should you use? - (2012-11-18)
  [4069] Even early on, separate out your program from your HTML! - (2013-04-25)
  [4118] We not only teach PHP and Python - we teach good PHP and Python Practice! - (2013-06-18)
  [4326] Learning to program - comments, documentation and test code - (2014-11-22)
  [4641] Using an MVC structure - even without a formal framework - (2016-02-07)
  [4691] Real life PHP application using our course training MVC example - (2016-06-05)

G996 - Well House Consultants - Newsletter Scripts
  [1001] .pdf files - upload via PHP, store in MySQL, retrieve - (2006-12-19)
  [1066] Final, Finally and Finalize - three special words in Java - (2007-02-05)
  [1123] mysqldump and mysqlrestore - (2007-03-30)
  [1217] What are factory and singleton classes? - (2007-06-04)
  [1387] Error logging to file not browser in PHP - (2007-10-11)
  [1505] Script to present commonly used images - PHP - (2008-01-13)
  [1601] Replacing the last comma with an and - (2008-04-04)
  [1665] Factory method example - Perl - (2008-06-04)
  [1743] First class functions in Lua lead to powerful OO facilities - (2008-08-07)
  [1813] Ajax - going Asyncronous and what it means - (2008-09-28)
  [1954] mod_rewrite for newcomers - (2008-12-20)
  [2046] Finding variations on a surname - (2009-02-17)
  [2145] Using the internet to remotely check for power failure at home (PHP) - (2009-04-29)
  [2259] Grouping rows for a summary report - MySQL and PHP - (2009-06-27)
  [2360] Error Handling in Lua with assert and pcall - (2009-08-13)
  [2433] Controlling, supressing, enabling PHP error messages - (2009-10-02)
  [2539] Changing Images - (2009-12-17)
  [3179] Oops - I typed ci not vi, and have lost my file ... - (2011-02-21)


Back to
Perl for Larger Projects - Object Oriented Perl
Previous and next
or
Horse's mouth home
Forward to
Flash - is it available to your web page?
Some other Articles
Java - Client side applet applications as well as server side
Well House Manor appoints a General Manager
Flash - is it available to your web page?
Resetting session based tests in PHP
Perl for Larger Projects - Object Oriented Perl
Customer feedback - lifeblood of a business
Well House Manor - feature comparison against the old place!
2008 course schedule - Perl, Python, PHP, Linux, Java Deployment, Ruby and more
Filtering and altering Perl lists with grep and map
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/1321_Res ... n-PHP.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb