Archive for May 2006
The issue of empty session files
I wrote two small scripts to test:
//first.php
<?php
session_start();
$_SESSION["session_test"] = "session testing";
print $_SESSION["session_test"]."<br>";
print '<a href = "second.php">Second Page</a><br>';
print session_id();
?>
If sessions are working properly then the session id should be the same in both pages and
that offers a very simple test apart from the fact that the test string should also be shown
in the second page.
The second page script looks like this:
//second.php
<?php
session_start();
print $_SESSION["session_test"]."<br>";
print session_id();
?>
On clicking the link to the second page, the second page had a different session id and the
the test string never showed but instead I got this warning : Notice: Undefined index:
session_test in C:\webroot\second.php on line 3. (after enabling all errors and warning
to show).
After hours of toiling I found out that this issue was caused by the Zone Alarm firewall. I
disabled the firewall and the sessions started working. I have looked through the firewall
log and I cant see exactly where localhost or PHPSESSID is blocked and so for now I will
temporarily disable the firewall when testing script involving sessions and if I cant find a
solution then it could be time to move to another firewall.
Getting Apache 2.2 to work with PHP 5
What I will do though is to highlight the small changes I made to make Apache 2.2 work with PHP 5.
Assuming PHP is installed in the C:/php folder normally you would add the following lines to your Apache httpd.conf file:
LoadModule php5_module "C:/php/php5apache2.dll"
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
# configure the path to php.ini
PHPIniDir "C:/php"
With Apache 2.2 I got an error on the LoadModule line. To resolve that error I had to download the latest stable release of PHP from the PHP Snapshots site. I downloaded the zip file for PHP 5.2 and this comes with the php5apache2_2.dll file.
In the Apache httpd conf file I then made changes to the LoadModule line as follows:
LoadModule php5_module "C:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
# configure the path to php.ini
PHPIniDir "C:/php"
and this solved the problem. I prefer using the PHPIniDir directive because this means I
just maintain one copy of the php.ini file in C:/php folder in this case and I don't have to
copy another one to C:/Windows for example and this works fine for me.
Registry Clean Up time
Although CCleaner can do a lot more cleaning than just resolve registry issues
like delete cookies and empty recycle bin for now I will perform all
those other functions manually.
File transfer using FileZilla
I have always tended to use my host's File Manager for file transfer and its alright as long as I am dealing with a few files. Unfortunately thats not always the case hence my need for good FTP client software. With FileZilla I can just copy entire folders from the local machine to the remote machine something I cant do with my host's File Manager.
You can also go ahead and rename the files and folders and perform whatever manipulation but what's exciting about it all is the speed of execution. Everything looks like its running on the local machine.
However, its a good idea to go on and make sure that the transferred files or folders have the desired permissions once they have been transferred. My test files 'lost' their permission settings after transferring and I had to reset the permissions. For example some of the files had just read only access but they ended up with read and write. Its an easy process to change file permissions though through FileZilla as this is handled quite neatly and as always its good practice to check that files and folders have permissions you intended in the first place whatever method you use for file transfer.
The C++ source code is also available for download should one want to look at the code.
I was also quite pleased with the fact that I just downloaded and installed FileZilla and it
worked using the default settings. Obviously I will now start tinkering about and modify the
settings to suit my particular needs.