Training, Open Source computer languages

PerlPHPPythonMySQLhttpd / TomcatTclRubyJavaC and C++LinuxCSS

Search our site for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
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 07:23:47)

 
Associated topics are indexed under
H116 - Shopping Cart Application in PHP
H115 - Designing PHP-Based Solutions: Best Practice

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
Easy handling of errors in PHP
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
1638 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 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).

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